cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hpkeong
Level 10

Re: Patch a Collection

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.

 

Edit.pngBatch Editing of Records and Replace

 

hpkeong
PowerApps Staff rgruian
PowerApps Staff

Re: Patch a Collection

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
KrunalPatel
Level: Powered On

Re: Patch a Collection

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

Meneghino
Level 10

Re: Patch a Collection

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"))

 

KrunalPatel
Level: Powered On

Re: Patch a Collection

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

 

 

Meneghino
Level 10

Re: Patch a Collection

Hi @KrunalPatel, let me test this.

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

KrunalPatel
Level: Powered On

Re: Patch a Collection

Hi @Meneghino,

 

My datasource is SharePoint list.

Meneghino
Level 10

Re: Patch a Collection

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:

https://powerusers.microsoft.com/t5/PowerApps-Forum/Solved-patching-to-SharePoint-choice-and-lookup-...

KrunalPatel
Level: Powered On

Re: Patch a Collection

Hi @Meneghino,

 

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

Meneghino
Level 10

Re: Patch a Collection

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

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
Users Online
Currently online: 101 members 5,393 guests
Please welcome our newest community members: