0

I have this gallery >> when the user click on the + icon >> i will add a new empty record inside the SharePoint list >> then the user will enter the related info >> click on submit to update the gallery items:.

Here is the gallery:-

enter image description here

and here is the formula to ForAll the GalleryItems and update the SharePoint item:-

ForAll(PrintOrderDetailsGallery.AllItems, Patch('Printing Orders Details',ThisRecord,{Quantity:PrintOrderQuantity,'Quantity Each Artwork':PrintOrderQuantityForEachartwork.Text,'Network ID':PrintOrderNetworkComboBox.Selected.ID})); 

but currently the ForAll will not update the sharepoint list? any advice?

1 Answer 1

1

Fix:

If you want to update items already saved on SharePoint (but with no value, only auto generated ID), you can use a LookUp on the SharePoint datasource and filter on ID, instead of using ThisRecord. Something like that:

 Patch('Printing Orders Details', LookUp('Printing Orders Details', ID = 100), { 'Quantity': 123, 'Quantity Each Artwork': 456, 'Network ID': 789 } ) 

Improvement:

Using a Patch in a ForAll could be slow. There is a technique to Patch a collection, without a ForAll. You can check this great article of Matthew Devaney: PATCH Multiple Records In Power Apps 10x Faster

I don't think you can apply this trick directly in your code (you must store the empty lines in a collection), but it could be something like that:

Patch('Printing Orders Details', PrintOrderDetailsGalleryCollection) 

Video:

As you are trying to make an editable gallery, you need to check this video form Reza Dorrani: Power Apps Editable Grid using Gallery & Modern Controls (2023). The same trick as Matthew is used: collect your empty items in a collection and do something like Patch(SharePointSource, EditableItemsCollection)

10
  • Thanks for the reply, but in my case the items inside the gallery are not saved yet to sharepoint, so how i can loop through them? Commented Nov 4, 2023 at 8:47
  • When you said "i will add a new empty record inside the SharePoint list" I thought you have created empty items in SharePoint and that's why you wanted to update them. If not, you have to create, not update, the items. It's simpler. I will edit my answer. Commented Nov 4, 2023 at 9:00
  • yes i already created them as empty inside sharepoint, Commented Nov 4, 2023 at 9:14
  • i tired your code but it did not update the SharePoint list item,, also i can not access the datacard using ThisRecord Commented Nov 4, 2023 at 9:27
  • I don't understand why to talk about "update" SharePoint list if you want to "create" new items. It's very confusing. Maybe you have to edit your initial question. Patch + Defaults will create new item in the datasource for sure. Commented Nov 4, 2023 at 9:44

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.