Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Re: How to bulk update with ForAll or Patch

You can mass batch into a datasource by first collecting the items you want to batch into a temporary collection. Make sure this collection has the same columns as your datasource. Then collect the temporary collection into your datasource. Then clear your temporary collection so that it does not keep getting larger everytime you want to hit the button.


Note: Errors will appear if your default values in the datasource do not match the values in the temporary collection. Example of this was the date. The datasource was DateTimeFormat, but when i first collected it was text. Added DateTimeValue in front as per below, and it fixed the error.


Example formatting below:


Step 1 - collect items in temporary collection:


DateRequested:DateTimeValue(Text(Now(),"[$-en-US]mm/dd/yyyy hh:mm:ss")),


Step 2: Collect collection into datasource:




Step 3: Clear temporary collection:



Advocate IV
Advocate IV

Re: How to bulk update with ForAll or Patch

When people ask for better documentation, it's because of useless examples liek this:

Patch(Cars, Table( { Id: 12, Brand: "Audi", Model: "A7" }, { Id: 24, Brand: "Volvo", Model: "S6" } ))


Why, in what world ever, would users create a hard coded table with values and pass that into Patch()?


How about a useful example, like I have a gallery called MyGallery. It has item collection, MyGallery.AllItems.

User is changing a number of the records in that gallery, and I want user to press a button to update all the records in a single submit.


I would expect to be able to do this:


and that would update the datasource. But it doesn't, and doesn't give any error messages, so what is the method of updating datasource based on changes to the record collection?

Frequent Visitor

Re: How to bulk update with ForAll or Patch



First off, submit a new question next time on a new thread. But since you asked...


MyGallery.AllItems has more items than in my datasource. MyGallery.AllItems contains a "nextarrow" etc. that is incompatible with the column headers in the datasource. When you patch, the columns in the datasource need to match the columns in the item you want to patch. Therefore by collecting those items from MyGallery.AllItems, you are able to use patch as you mentioned above. To do this make a temporary collection:


Collect(CallThisCollectionAnythingYouWant, ForAll(MyGallery.AllItems,{Column1Name:PickSomethingInMyGallery.AllItemsToCollectHereForThisColumn,Column2Name:PickSomething,Column3Name:PickSomething....}))






Put all the above on one button, and it will do as you require.

If you use a form, just use Submit(Form) and it will put everything into the table (for a new form, continue reading for editform).


For editing certain records it is more tricky. You will need to filter your datasource for that record before applying patch. Patch(First(Filter(Datasource,ColumnInDataSource=something,AddMoreFiltersWithCommaAsRequired)),{Column1:ChangetosomethinginMyGallery.AllItems,Column2:ChangetosomethinginMyGallery.AllItems,....})

Patching can edit more than one item in your datasource, but you need to filter for what you want to edit. Don't forget you can LookUp() items if they are not in MyGallery.AllItems (ie. in another datasource).


Alternately, you can make a gallery with all the items you want in your datasource, then on the select arrow OnSelect = EditForm(Form). Create a form either on a new page (add navigate to that page after EditForm(Form);Navigate(tothepagewithyourform), or learn how to use UpdateContext() on the on visible section of a form to show it. Fill out the form, and then with the submit button OnSelect = Submit(Form). This will edit items in your datasource, row by row.

Advocate IV
Advocate IV

Re: How to bulk update with ForAll or Patch

Hi SCambel.


Thanks for the very detailed descriptions, that helps a lot.

Helpful resources


New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (5,201)