I have this gallery which contain items that were already created inside SharePoint, and i want to loop through them and update the items, when clicking on the Submit button:-
I tried the below formula inside the submit button, but the issue is that all the items will get the last gallery's item values, so in the above example all items will have Quantity = 300 and Quantity Each Network = 500, and so on:-
Patch('Printing Orders Details',
ForAll(PrintOrderDetailsGallery.AllItems,
{ ID: ID,
Quantity: Value(PrintOrderQuantity.Text),
'Quantity Each Artwork':PrintOrderQuantityForEachartwork.Text,
'Network ID':PrintOrderNetworkComboBox.Selected.ID
}
)
)
and advice?
@ANB did you try to update multiple rows at the same time,, as based on my test iteration over the gallery items and update them inside the same forAll will not work, as the gallery will be cleared out after the first update
I tried on my end and shown the screenshots also, so not sure why it is not working for you. However, But please check the video that I suggested.
Thanks,
ANB
@ANB all the items that get updated inside the ForAll will have the same values... i think accessing the gallery item using the control names will get the same values for all the gallery items
@johnjohn123 , What is the error? Did you made the PrintOrderQuantity control which is within your gallery to number type? The video that I suggested, did you tried that?
Thanks,
ANB
@ANB i removed the container,, but still can not get things working for me
@johnjohn123 , This is what I can suggest as of now. Where you will still have responsive gallery. Please check this video by Reza: https://www.youtube.com/watch?v=8I0Pt_8I6k8&t=708s
He is first locally collecting the updates in collection and then finally in one go patch the changes to data source.
He is using dataverse, but you can use SP list. Please check complete video.
-----------------------------------------------------------------------------------------------------------------------------
I hope this helps.
Please click Accept as solution ✅ if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍
Thanks,
ANB
Yeah, We cannot access controls which are within container. I just tested. Then in that case you might have to think with different way.
Thanks,
ANB
ok i got your point, but now in my case i can not for example write this formula:-
var.PrintOrderQuantity.Text
as the PrintOrderQuantity control is added inside the gallery container and not directly inside the gallery.. so seems containers does not expose the controls inside them as mentioned in this post https://powerusers.microsoft.com/t5/Building-Power-Apps/ForAll-Collect-text-input-inside-a-container-inside-a-gallery/td-p/2350797 .. not sure how i can fix this?
This is only difference. Let me try to add container and then will check and update you.
Thanks,
ANB
@johnjohn123 One thing i suspect is that, can you make the PrintOrderQuantity control which is within your gallery to number type:
And the try this:
ForAll(PrintOrderDetailsGallery.AllItems As var,
Patch('Printing Orders Details',
Lookup('Printing Orders Details', ID = var.ID),
{
Quantity: var.PrintOrderQuantity.Text,
'Quantity Each Artwork':var.PrintOrderQuantityForEachartwork.Text,
'Network ID':var.PrintOrderNetworkComboBox.Selected.ID
}
)
)
-----------------------------------------------------------------------------------------------------------------------------
I hope this helps.
Please click Accept as solution ✅ if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍
Thanks,
ANB