web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Loop and update all Re...
Power Apps
Answered

Loop and update all Records in a gallery

(0) ShareShare
ReportReport
Posted on by 53

Hi all, 

 

I am looking for a way how to update all records in a Gallery when the user updates the values. Scenario is as follows; 

 

My gallery named InvoiceLinesGallery with Data Source Table Invoice Lines is as follows; 

GAllery.png

 

I would like to save the values the user changes example if user changes descriptions of one or more lines, the new values are saved per record. By using ForAll to loop the gallery and Patch to update all changed records, how can I lookup each record in the Invoice Lines Table and patch (update) it? This is what I have come up with so far; 

 

ForAll(InvoiceLinesGallery.AllItems, Patch('Invoice Lines',LookUp('Invoice Lines', 'Invoice Line' = *reference record ID of current gallery item being looped*), {Description: [@LinesDescriptionTextBox].Text}, {UnitPrice: Value([@LinesUnitPriceTextBox].Text)}, {Quantity: Value([@LinesQtyTextBox].Text)}, {GLAccount:[@LinesGLAccountDropdown].Selected}));

 

where 'Invoice Line' is the record's GUID identifier column. 

 

Also, should the textboxes be referenced with the '@' i.e. [@LinesGLAccountDropdown]? 

 

Thanks in advance! 

 

Categories:
  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @yabela ,

     

    You can try below code if it helps. Please update according to your requirement. 

     

    ForAll(InvoiceLinesGallery.AllItems, 
    UpdateIf('Invoice Lines',ID = ThisRecord.ID*reference record ID of current gallery item being looped*, 
    {Description: ThisRecord.LinesDescriptionTextBox.Text, 
    UnitPrice: Value(ThisRecord.LinesUnitPriceTextBox.Text), 
    Quantity: Value(ThisRecord.LinesQtyTextBox.Text), 
    GLAccount:ThisRecord.LinesGLAccountDropdown.Selected.xxxx
    }
    )
    );

     

     

    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.

  • yabela Profile Picture
    53 on at

    Hi @PriyankaGeethik , 

     

    Thanks for your input 🙂 

    When I update the formula as per your instructions, I'm getting an error saying The requested operation is invalid. Server Response: Invoice Lines failed: The right side of the "Equal" operator must be a constant value

     

    This is my formula: 

     

    ForAll(InvoiceLinesGallery.AllItems, Patch('Invoice Lines',LookUp('Invoice Lines', 'Invoice Line' = ThisRecord.'Invoice Line'), {Description: [@LinesDescriptionTextBox].Text}, {UnitPrice: Value([@LinesUnitPriceTextBox].Text)}, {Quantity: Value([@LinesQtyTextBox].Text)}, {GLAccount:[@LinesGLAccountDropdown].Selected}));

     

    where 'Invoice Line' is the record's GUID identifier column. 

     

    What is wrong in this case? 

     

    Thanks! 

     

  • Verified answer
    PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @yabela ,

    In the formula you are trying to update the Invoice Line with the same records data ? If you want the same data to be added again no need to updating that column. 

     

    Try below code. Only update the xxxx and keep rest same. 

     

    ForAll(InvoiceLinesGallery.AllItems, 
    UpdateIf('Invoice Lines',ID = ThisRecord.ID, 
    {Description: ThisRecord.LinesDescriptionTextBox.Text, 
    UnitPrice: Value(ThisRecord.LinesUnitPriceTextBox.Text), 
    Quantity: Value(ThisRecord.LinesQtyTextBox.Text), 
    GLAccount:ThisRecord.LinesGLAccountDropdown.Selected.xxxx
    }
    )
    );

     

     

    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.

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard