Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

How to update all gallery records fast

Posted on by 214
I have a set up to display questions for an exam 
 
More than 60 questions are displayed in a gallery, the teacher has to edit occasionally 5 or 10 rows for an existing exam, depending on whether they forgot to add data
 
The usual patch is very slow, it seems I have to scroll up and down so it can 'read' all the records, is there a more efficient way? 
 
I tried Matthew's solution but it doesn't seem to do it at all, I guess it doesn't have the gallery data so unsure how it would be able to do it 
 
 
Current code
 
// Update each question's 'Actual Score' and 'Comments' in the Question's table
ForAll(
    questions_gal_2.AllItems As Record,
    Patch(
        'Questions',
        LookUp('Questions', 'Questions Id' = Record.'Questions Id'),
        {
    'Actual Score': Record.score_cmb.Selected.Value,
    Comments: Record.comments_txt.Text
        }
    )
);
  • Verified answer
    Mark Nanneman Profile Picture
    Mark Nanneman 329 on at
    How to update all gallery records fast
    Hello, a few comments:

    A. Non Powerapps Solutions:
    What kind of data source is "Questions"?  If it's in SharePoint you could just go to that list in SharePoint, filter it how you like (or create a View) and click "Edit in grid view", then you can edit the datasource almost like you're in Excel.  There are similar things you can do if the datasource is in Dataverse.

    B.  Speed up your "For All"
    You could speed up your "ForAll" significantly by removing the "LookUp" part.  That's almost certainly redundant and slowing it down.  Just try replacing that whole LookUp function with "Record".  Doing a lookup to get the record that you already have in your "ForAll" can almost double the time it takes to do each item in your "ForAll".

    C.  The Batch Patch Method
    You could use the method described by Matthew Devaney but you'd have to somehow collect an updated version of each item (with at least the Key column(s) and the columns you want to update) and then Patch that collection to the datasource.

    D.  Why not just update as you edit each item?
    That said, If all you're doing is patching two simple columns, a score and a comment field, why not just patch those updates as they're entered?  The user would probably hardly notice.
     
    You could either have "OnChange" Patches for the controls in your gallery, something like putting "Patch(Questions, ThisItem, {'Actual Score': Self.Selected.Value})" in the "OnChange" of the score_cmb control, or you could add a simple form that uses the selected question from the gallery as its item.  Then you can add the score and comment field to display/edit on the form, and add a submit button.

    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff  | Buy me a coffee
  • Suggested answer
    KeithAtherton Profile Picture
    KeithAtherton 3,649 on at
    How to update all gallery records fast
    Hey. I've used the schema match approach mentioned in Matthew Devaney's article before which has given the best performance I've seen so far.
     
    I think it could be adapted to retrieve all rows from the gallery (questions_gal_2.AllItems) then perform the schema match approach instead of using the ForAll loop.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,532

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,050

Leaderboard