cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rhemo
Level 8

patch for all items in a gallery

Im having trouble updating records with the following code:

 

Patch(Table1,ForAll(Gallery1.AllItems,{Attendance: Toggle1.Value, Notes: TextInput2.Text}))

 

It is creating new records and I do not understand why should this not be updating the existing records??

20 REPLIES 20
Leo09
Level 8

Re: patch for all items in a gallery

I do not know why did you use the ForAll function. Would you explain more on this formula?

Forall function:

https://powerapps.microsoft.com/en-us/tutorials/function-forall/

Patch function:

https://powerapps.microsoft.com/en-us/tutorials/function-patch/

Rhemo
Level 8

Re: patch for all items in a gallery

HI Leo,

Gallery1 displays records based on dropdown menus which act as filters, i have a toggle switch which the user can mark and a section for notes that can be filled in. So I was attempting to using the forall(gallery1.allitems) as a record source for the patch function to update the Table1 datasource for the records in gallery1.

Meneghino
Level 10

Re: patch for all items in a gallery

Hi @Rhemo

Something like this will work:

 

ForAll(Gallery1.AllItems, Patch(Table1, {ID: Gallery1.AllItems.ID}, {Attendance: Toggle1.Value, Notes: TextInput2.Text}))

Your problem was that you were not using the correct syntax for the Patch, which to update an existing record is: Patch (MySource, MyExistingRecord, UpdateRecord)

 

I am not sure that ID: Gallery1.AllItems.ID will work above, it will depend on what the primary key column of your Table1 is.

 

Please let me know how you get on and I can help you further.

 

PS The use of ForAll will patch the record updates one at a time.  There may be an alternative using just Patch with a table of changes, and this might perform better.  In order to help you I need to know the primary ID column of your Table1 and the Items property of Gallery1

Rhemo
Level 8

Re: patch for all items in a gallery

HI Meneghino,

many thanks for your reply, the datasource is an excel file, i assume the primary ID would be the __PowerAppsId__ thats created automatically by powerapps? I did not specifically create a primary ID column

Meneghino
Level 10

Re: patch for all items in a gallery

Hi @Rhemo

Yes, indeed.  I have not used Excel tables as data sources so I am not too sure, but something like this could work:

ForAll(Gallery1.AllItems, Patch(Table1, {PowerAppsId: Gallery1.AllItems.PowerAppsId}, {Attendance: Toggle1.Value, Notes: TextInput2.Text}))

Does the column name also have all these leading and trailing ___ ?

 

If the above does not work, then try {PowerAppsId: PowerAppsId}  (I know it looks strange)

 

And if this does not work, then we can rename the column in Gallery1.AllItems to disambiguate.  But will do that if needed, please let me know how you get on.

Rhemo
Level 8

Re: patch for all items in a gallery

Hi Meneghino,

tried as you suggested with no luck, yes in excel the powerappid has the leading and trailing "__", powerapps says the specified column does not exist.

Meneghino
Level 10

Re: patch for all items in a gallery

Then, have you tried?

 

ForAll(Gallery1.AllItems, Patch(Table1, {___PowerAppsId___: Gallery1.AllItems.___PowerAppsId___}, {Attendance: Toggle1.Value, Notes: TextInput2.Text}))

Any luck?

Rhemo
Level 8

Re: patch for all items in a gallery

powerapps_err.jpg

 

no luck im afraid

Meneghino
Level 10

Re: patch for all items in a gallery

What expression do you have for the Items property of Gallery1?

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,685)