web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power Apps Patch Function
Power Apps
Unanswered

Power Apps Patch Function

(1) ShareShare
ReportReport
Posted on by 67
Hi Members,
 
I have a SharePoint list as "Desk Reservation Details", with a column: Desk Name [Lookup column], these column allows multiple values.
 
I was developing a application for Desk Reservation. On the Power Apps screen I have added a 9 button controls from Desk 1 to Desk 9. Whenever the user selects a button desk name as Desk 1 and Desk 2 and clicks on a Book Button control, those values should be saved to the SharePoint list.
 
For the each desk button control, The code I used for all desk buttons:
 
OnSelect :If(
          Find("Desk1,", varSelectedDesks) > 0, 
           // If Desk 1 is already selected, remove it from varSelectedDesks
           Set(varSelectedDesks, Substitute(varSelectedDesks, "Desk1,", "")),
           // If Desk 1 is not selected, add it to varSelectedDesks
           Set(varSelectedDesks, Coalesce(varSelectedDesks, "") & "Desk1,")
          );

Fill: If(
      Find("Desk1,", varSelectedDesks) > 0,
      Color.White,  // Turns white if Desk 1 is selected
      var_ThemeColor   // Default color (or any other color you prefer)
      )

Visible: If(
         !IsBlank(
          LookUp(
            'Desk Reservation Details_1',
            'Reservation Date' = DataCardValue3.SelectedDate &&
            'Desk Name' .Value= "Desk 1" &&
             'Reservation Status'.Value = "Booked"
           )
          ),
          false,true)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
In Book button control, OnSelect property, i have used the code as:
Patch('Desk Reservation Details_1',Defaults('Desk Reservation Details_1'),{Title:ReserveTitle,'Reservation Date':DataCardValue3.SelectedDate,'Reserved By':User().FullName,'Reservation Status':{Value:"Booked"},'Desk Name':varSelectedDesks})
But, I am facing the error as "Does not match expected type table, expected type text"

 
 
 
 
 
 
 
 
 
 
 
 
How to save the selected Desk button names to SharePoint list, if the user select Desk 1 and Desk 2. 
Please, Help me how to achieve this. Thanks in Advance!
 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    152,843 Most Valuable Professional on at
    Power Apps Patch Function
    You have caused yourself a lot of complication using a Lookup field here (they are not really necessary with Power Apps and I never use them). What you have not posted is the field name in varSelectedDesks with the Desk details - I have assumed Value here when using _Data.Value - change this if the name is different. You also need to use the List and Field name you are looking up. Please also confirm that varSelectedDesks is a Table variable as it appears that it may be Text.
    Patch(
       'Desk Reservation Details_1',
       Defaults('Desk Reservation Details_1'),
       {
          Title: ReserveTitle,
          'Reservation Date': DataCardValue3.SelectedDate,
          'Reserved By': User().FullName,
          'Reservation Status': {Value: "Booked"},
          'Desk Name': 
          ForAll(
             varSelectedDesks As _Data,
             {
                Value: _Data.Value,
                Id:
                LookUp(
                   YourOtherList,
                   YourLookedUpField = _Data.Value
                ).ID
             }
          )
       }
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 836 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 231 Super User 2025 Season 2

Last 30 days Overall leaderboard