Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

ForAll gallery items will get the last gallery item values

(0) ShareShare
ReportReport
Posted on by 3,502

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:-

 

johnjohn123_4-1699094630697.png

 

johnjohn123_5-1699094662053.png

 

 

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?

  • johnjohn123 Profile Picture
    johnjohn123 3,502 on at
    Re: ForAll gallery items will get the last gallery item values

    @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

  • ANB Profile Picture
    ANB 7,060 on at
    Re: ForAll gallery items will get the last gallery item values

    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

  • johnjohn123 Profile Picture
    johnjohn123 3,502 on at
    Re: ForAll gallery items will get the last gallery item values

    @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

  • ANB Profile Picture
    ANB 7,060 on at
    Re: ForAll gallery items will get the last gallery item values

    @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

  • johnjohn123 Profile Picture
    johnjohn123 3,502 on at
    Re: ForAll gallery items will get the last gallery item values

    @ANB i removed the container,, but still can not get things working for me

  • ANB Profile Picture
    ANB 7,060 on at
    Re: ForAll gallery items will get the last gallery item values

    @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


  • ANB Profile Picture
    ANB 7,060 on at
    Re: ForAll gallery items will get the last gallery item values

    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

  • johnjohn123 Profile Picture
    johnjohn123 3,502 on at
    Re: ForAll gallery items will get the last gallery item values

     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?

    @ANB

  • ANB Profile Picture
    ANB 7,060 on at
    Re: ForAll gallery items will get the last gallery item values

    This is only difference. Let me try to add container and then will check and update you.

     

    Thanks,

    ANB

  • ANB Profile Picture
    ANB 7,060 on at
    Re: ForAll gallery items will get the last gallery item values

    @johnjohn123  One thing i suspect is that, can you make the PrintOrderQuantity control which is within your gallery to number type:

    ANB_1-1699103210931.png

    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


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard