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 / Only Update Select Ite...
Power Apps
Answered

Only Update Select Items in Gallery

(0) ShareShare
ReportReport
Posted on by 18

Hi All,

 

I have a gallery that is setup to look similar to an Excel table, where the gallery has input boxes instead of labels connected to my SharePoint list.

 

The idea is for users to be able to come into the app and update certain column values for each row. They will likely only be updating one column at a time, but I want them to be able to do this for multiple rows at once (as opposed to one row at a time in a form).

 

The issue I'm having is that the Patch function I currently have on a "Save Changes" button is adding a row every time instead of updating an existing row. Basically, I want to be able to do a bulk update that writes back whichever few rows were changed instead of adding all new rows to the SharePoint list. Would love some guidance on how I can accomplish this.

 

This is the function I currently have where ExistingID.Text is the unique ID from Sharepoint that I have embedded into each row of my gallery.

ForAll(ReportGallery.AllItems,
 Patch(
 'Report Audit',
 LookUp(
 'Report Audit',
 ID = Value(ExistingID.Text), 
 {
 Date: ExistingDueDateInput.Text,
 Area: ExistingAreaInput.Text,
 'Report Name': ExistingReportNameInput.Text,
 Owner: ExistingOwnerInput.Text,
 Reviewer: ExistingReviewerInput.Text
 }
 )
 )
);

 

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @cmnflom 

    To start, your formula has the ForAll backward. You are trying to use it like a ForLoop in some development language - which PowerApps is not.  It is a function that returns a table of records based on your iteration table and record schema.

    It is more efficient to use the function as intended and will provide better performance.

     

    Please consider changing your Formula to the following:

    Patch('Report Audit',
     ForAll(ReportGallery.AllItems,
     {
     ID: ID, //See note below
     Date: ExistingDueDateInput.Text,
     Area: ExistingAreaInput.Text,
     'Report Name': ExistingReportNameInput.Text,
     Owner: ExistingOwnerInput.Text,
     Reviewer: ExistingReviewerInput.Text
     }
     )
     ;

     

    Your Items property of your gallery should include all of the columns from your datasource that you need.  Especially, it should include the ID of the record.  Then, it is included as shown in the above formula.

    This goes for all the other "Existings" too in your formula.  If those are just controls to hold the values of the underlying column value, then you can get rid of all of that and just use the column value directly in your formula.

     

    Patch will take a table of records to work with - this is the purpose of the ForAll function, to create a table, not to loop through functions.

    So, ForAll will create the table of records and pass to patch - which will then be instantiated only once (for performance purposes) and Patch will then work with all the records in the table.

    Patch is smart enough to know that if a primary key is included, then it will update the record with that primary key.  If it is not included or blank, then it will create a record for the data.  There is nothing more that you need to do.  Just supply the primary key (ID in this case).

     

    I hope this is helpful for you.

  • cmnflom Profile Picture
    18 on at

    Thank you very much! This worked like a charm. Appreciate the help 😊

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard