Showing results for 
Search instead for 
Did you mean: 
Community Champion
Community Champion

Patch a Collection

The release notes for 2.0.531 indicates an improvement to the Patch function that I'm excited about: 



7. Update multiple records at once by using the Patch function.

Create or update more than one record at a time by specifying a table of base records and 
a table of change records as arguments for the Patch function.


I think this is what I've been waiting for, but I'm not sure how to use it. 


Can I save a Collection with identical fields back to the datasource? For instance, can I Patch the rows in Collection1 into DataSource1 if they have identical columns? I've been trying:




but that does not result in any new rows written. What am I doing wrong?



EDIT: could it be that the default fields (Title, CreatedOnDateTime, etc.) are blank in the Collection, so it cannot be Patched with those blank?

Microsoft Employee
Community Champion
Community Champion



Thanks a lot.

Looks like, as you have posted, there are several ways of PATCH syntax.

1. Patch(DS, Collection) - DONE!

2. Patch(DS, BaseRecordsTable, use ForALL) - DONE!


For No. 2, I had tried to understand ForALL and found it needs some effort to understand the requirements beneath and good to be combined with Patch. Think simple..this is what I capture from your sharing.


I try to post here of what I had accomplished.

So, it is clear that:

- Use Collect a batch of New Record and Patch in Batch

- Use Filtering (with Dropdown, ListBox,..) and use Gallery + TextInput to list WISH-List for Editing (Modifying) and PATCH (Replace) in Batch.

This greatly improve the:

- Saving speed (as all data are cloud-linked)

- Editing speed (batch edit and batch saving).


Ocne again, my appreciation.

I shall try other options as suggested and I wish my examle posted here can be helpful to others as well as PG in amending the existing Learn Tutorial to give others a clearer and Practical way of using Patch + ForAll for BATCH DATA processing.


Batch Editing of Records and ReplaceBatch Editing of Records and Replace



I am glad this helped. As you hinted -- think functionally instead of imperatively. PowerApps is really optimized for the former, very much like Excel is. In the process, you will likely find that functional solutions tend to be more concise.

Radu Gruian [MSFT] ** PowerApps Staff



I am trying to use this code


Button2.OnSelect = Patch(TableBook, SourceBook, ForAll(Gallery1.AllItems, { Book: TextInput1.Text, Author: TextInput2.Text, Language: TextInput3.Text }))


But I am getting the error "Invalid Argument type (Table). Expecting a record value instead". And If I am trying to add collection directly then also I am not able to add new records to the List(datasource).



Hi @KrunalPatel

Try this:


Button2.OnSelect = Patch(TableBook, SourceBook, ShowColumns(AddColumns(Gallery1.AllItems,  "Book", TextInput1.Text, "Author", TextInput2.Text, "Language", TextInput3.Text), "Book", "Author", "Language"))


Hi @Meneghino,


I am using the exact code as specified but I am getting the error


This is my expression


Patch(Answer, Defaults(Answer), ShowColumns(AddColumns(BrowseGallery1_1.AllItems,  "Title", Heading1_1.Text, "SelectedChoice", TextBox4.Text), "Title", "SelectedChoice"))


But I am getting error





Hi @KrunalPatel, let me test this.

What is your data source? (i.e. CDS, SQL Server, SharePoint list...)

Hi @Meneghino,


My datasource is SharePoint list.

What are the column types? Are they all text or do you also have a choice or lookup column?

If so, please also have a look at this:

Hi @Meneghino,


My column type is single line of text for both fields. No Lookup or choice field.

This worked for me when creating new records in Answer, a SharePoint list:


Collect(Answer, ShowColumns(AddColumns(BrowseGallery1_1.AllItems,  "Title", Heading1_1.Text, "SelectedChoice", TextBox4.Text), "Title", "SelectedChoice"))

Please let me know.

Helpful resources

Ignite 2022


Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (4,487)