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:
Patch(DataSource1,Collection1)
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?
Hi
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 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.
Hi,
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).
Thanks
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
Thanks
Hi @KrunalPatel, let me test this.
What is your data source? (i.e. CDS, SQL Server, 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:
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.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
207 | |
187 | |
83 | |
53 | |
37 |
User | Count |
---|---|
288 | |
246 | |
119 | |
78 | |
55 |