cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Patch to multiple rows

Halllo,

 

I can not figure out this problem. 

 

I have a gallery "1 " with a checkbox inserted. when the user checks a box , it's added to a collection. 

 

On a other page , i have a gallery "3"  with the items property set to that collection. ( only the items that the users has checked from gallery "1" ) 

I want to patch a text value to all items in that gallery. 

This is what i have , but nothing happens: 

ForAll(Gallery3.AllItems ; Patch('B-Transport Operations'; {'Naam_B-TO_tekst': Label4.Text }))

 

gallery 3 contains the items that are checked from gallery "1"

B-Transport Operations = Sharepointlist 

'naam_B-TO_tekst is the textcolumn in sharepoint

Label.4Text is the value that has to be patched to all items of gallery 3

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper III
Helper III

Re: Patch to multiple rows

Following formula is working: 

 

ForAll(RenameColumns( Filter('B-Transport Operations'; Selectie = "JA" );"ID" ; "EID") ; Patch('B-Transport Operations' ; LookUp('B-Transport Operations'; ID = EID ); {'Naam_B-TO_tekst': Dropdown2.Selected.Value }))

 

 

Thank you all for the help. 

View solution in original post

7 REPLIES 7
Highlighted
Advocate I
Advocate I

Re: Patch to multiple rows

Hi Stijn

 

It looks like there is another thread that addresses this. You can use Collect instead of Patch. Here is the link to the thread:

 

https://powerusers.microsoft.com/t5/Building-Power-Apps/Patch-all-items-in-Gallery/m-p/396014/highli... 

 

Thanks!

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Highlighted
Helper III
Helper III

Re: Patch to multiple rows

i tried it , but in the sharepointlist , new records are created ( added )

I want to selected items to be changed. 

 

My formula is now :

ForAll(Gallery3.AllItems ; Collect('B-Transport Operations'; {'Naam_B-TO_tekst': Label4.Text }))

 

@Doug_Apicella 

 

Highlighted
Microsoft
Microsoft

Re: Patch to multiple rows

Alternatively if you want Patch, you could use a below implementation : 

 

ForAll(Gallery1.AllItems,Patch(IceCream,First(Filter(IceCream,Flavor=Label1.Text)),{Quantity:<Value>}))

The Parameters are explained 
Gallery1 - is the Destination Gallery to which items needs to patched to
IceCream - Collection 

<Flavor=Label1.Text> - To get the specific row in the loop. You can modify the condition based on the requirement

  • Flavor - One of the column in the Collection 
  • Label1.Text - The value of the column

Quantity - The Column of the collection that you would like to Update

 
 

 

Highlighted
Super User
Super User

Re: Patch to multiple rows

Hi @Doug_Apicella 

This is one of the most common errors seen with the Patch() function.  It requires three elements,

  1.  The datasource being patched, can be an original connector datasource or a collection but it must be a table.
  2. The row in the datasource being patched.  If it is a new item being added then this element will be Defaults(TableName), if it is for modifying an existing row then usually it will be a formula that results in a row such as Lookup(TableName, ID=ThisItem.ID)
  3. The specific fields in the row being patched enclosed in curly brackets that indicate the columnname followed by a ":" then the  value being patched. {ID: Textbox1.Text} or {ContactName:Dropdown1.Selected.Value}

Most of the problems are forgetting to put in the row being patched, or having the incorrect column name.  This frequently occurs with SharePoint because the actual column names may not be the same as the name displayed in PowerApps.  Finally, if a collection is being used for a patch with the ForAll() function, it is helpful to disambiguate the field in the formula used to identify the row.  I have found that a good way is changing the name of the field in the collection using the RenameColumns function, then the new name can be used in the Lookup() formula.    

Highlighted
Super User
Super User

Re: Patch to multiple rows

@Stijn007 

I believe this video from Shane Young directly addresses your issue.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Highlighted
Helper III
Helper III

Re: Patch to multiple rows

Thanks for the support, 

 

I tried following formula, but it patches only the first item. 

 

ForAll(Gallery1.AllItems ; Patch('B-Transport Operations' ; First(Filter('B-Transport Operations' ; Selectie = "JA")); {'Naam_B-TO_tekst': Dropdown2.Selected.Value }))

 

I have created a textcolumn and when  an item is selected, it patches "JA" to the item. 

a second gallery ( gallery1)  is displayed with the selected items ( filter all items where the textcolumn "selectie" = "JA" 

Highlighted
Helper III
Helper III

Re: Patch to multiple rows

Following formula is working: 

 

ForAll(RenameColumns( Filter('B-Transport Operations'; Selectie = "JA" );"ID" ; "EID") ; Patch('B-Transport Operations' ; LookUp('B-Transport Operations'; ID = EID ); {'Naam_B-TO_tekst': Dropdown2.Selected.Value }))

 

 

Thank you all for the help. 

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (9,660)