cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RaifO
Frequent Visitor

Patching multiple items on nested gallery

Hi, it might be an easy solution but I tried few many ways to patch the changes on records to the Data source without success. Below is my SharePoint list which has multiple duplicated title.

Picture1.png

On PowerApps i have a nested gallery which all i want is to be able to change the "NAME" of the job owner without ticking all checkboxes in the nested gallery as it could be 100s of them.

I used collection to filter ticked checkboxes and ForAll/Patch to update the Data source

ForAll(RenameColumns(Filter(colall,IsChoosen),"ID","EID"),Patch(TEST,LookUp(TEST,ID=EID),{NAME:Body1_1.Text})).

 

Is there any way to workaround and able to update the all records with same "Title" in one go?

Many Thanks in advance..

 

 

Picture2.pngPicture3.png

2 ACCEPTED SOLUTIONS

Accepted Solutions
gabibalaban
Super User
Super User

@RaifO ,

I understand from your post that the solution works, but most probably is a very large time consumer which gives a bad user experience.

As @RandyHayes told me not long ago, the ForAll function is not meant to be used as for/loop, it's a function that returns a Table! So my proposal, supposing that your formula works, is:

 

Patch(
     Test,
     ForAll(Filter(colall,IsChoosen) As Temp_ColAll,
               {ID:Temp_ColAll.ID, NAME:Body1_1.Text}
     )
)

 

With this you'll send only one patch request to Sharepoint, rather than your formula which sends as many patch requests to Sharepoint as user selection. 

 

Hope it helps !

View solution in original post

@RaifO ,

I suppose that the code with Collect is based on button OnSelect Property. Collect() function will add records to your collection and is not updated existing records. So use patch:

ForAll(
     Gallery1.AllItems,
               Patch(collall,
                      {ID:ID},
                      {IsChoosen:"true"})
)

View solution in original post

4 REPLIES 4
gabibalaban
Super User
Super User

@RaifO ,

I understand from your post that the solution works, but most probably is a very large time consumer which gives a bad user experience.

As @RandyHayes told me not long ago, the ForAll function is not meant to be used as for/loop, it's a function that returns a Table! So my proposal, supposing that your formula works, is:

 

Patch(
     Test,
     ForAll(Filter(colall,IsChoosen) As Temp_ColAll,
               {ID:Temp_ColAll.ID, NAME:Body1_1.Text}
     )
)

 

With this you'll send only one patch request to Sharepoint, rather than your formula which sends as many patch requests to Sharepoint as user selection. 

 

Hope it helps !

View solution in original post

RaifO
Frequent Visitor

@gabibalaban 

Many thanks for your respond and i would like to say it worked great when I patched the chosen items from the collection.

However, it could be many items in the nested gallery which ticking the boxes one by one will be time consuming.

so i moved the nested gallery outside and created a rule that if Title on the "Browse Gallery1" and "Gallery1" matched automatically tick the checkbox". 

Picture2.png

Then with the below code, i patch the ticked gallery1 items to the collection, colall. 

ForAll(Gallery1.AllItems,Collect(colall,{IsChoosen:"true"}))

below formula shows me amount of items ticked in the collection but when i check the collection it seems "IsChoosen" column has no changes.

CountRows(Filter(colall,IsChoosen="true")) "

1.png

it's a bit strange that it doesn't updates the collection.

That is the part remained to complete the app, will be appreciate to hear your advise. how to push chosen items in Gallery1 to collection by not ticking each checkbox one by one.

 

Thanks

@RaifO ,

I suppose that the code with Collect is based on button OnSelect Property. Collect() function will add records to your collection and is not updated existing records. So use patch:

ForAll(
     Gallery1.AllItems,
               Patch(collall,
                      {ID:ID},
                      {IsChoosen:"true"})
)

View solution in original post

Hi @gabibalaban 

Many Thanks for your quick response and the solution. I did slight modification to the code you provided and tried to save some time. Rather than writing all columns and data cards, I've tried to patch Editform1 in one go 🙂 with the below code. Sadly, it doesn't patch the existing records but creates the new ones. 

Patch(
     TEST,
     ForAll(Filter(colall,IsChoosen="true") As Temp_ColAll,Editform1.Updates
     )
)

any spare time to use your expertise on this too?

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,119)