Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

LookUp inside Patch inside ForAll only updating the first record

(1) ShareShare
ReportReport
Posted on by 4
I am trying to Patch 2,250+ records at once using the on select of a button with the formula below. The two variables to filter by Due Date are established when navigating to this page and work fine inside the gallery itself. Problem is when the button is clicked, it updates the first record being displayed in the gallery appropriately but then sits "loading" (with the 5 dots scrolling across the top of the page) and never updates another record. Is there a better way to handle this type of request back to the SharePoint list?
 
ForAll(
    Gallery1.AllItems,
    Patch(
        'Master Sanitation List',
        LookUp(
            'Master Sanitation List',
            ThisRecord.ID = ID
        ),
        {'Reviewed by FSQA': "Yes",
        'Reviewed by FSQA On': Today(),
        'FSQA Review Completed By': {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Department: "",
                Claims: "i:0#.f|membership|" & varCurUser.Email,
                DisplayName: varCurUser.FullName,
                Email: varCurUser.Email,
                JobTitle: "",
                Picture: ""
            }
        }
    )
)
Categories:
  • Suggested answer
    TYSCC Profile Picture
    4 on at
    LookUp inside Patch inside ForAll only updating the first record
    Thank you all for the suggestions, I have actually reached the desired result via creating/updating a collection then patching that collection back to the SP List. Appreciate the advice from you all!  
  • MichaelFP Profile Picture
    1,827 Super User 2025 Season 1 on at
    LookUp inside Patch inside ForAll only updating the first record
    Hi! you can use With() inside for all for better control of the context. Because forAll could have concurrence so using With it will help for that.
     
    The With function evaluates a formula for a single record. The formula can calculate a value and/or perform actions, such as modifying data or working with a connection. Use the ForAll function to evaluate a formula for all the records in a table of records.
     
     
    Here sample based on you formula.
    ForAll(
        Gallery1.AllItems,
        With(LookUp(
                'Master Sanitation List',
                ThisRecord.ID = ID
            ) as RecordToUpdate,
        Patch(
            'Master Sanitation List',
            RecordToUpdate,
            {'Reviewed by FSQA': "Yes",
            'Reviewed by FSQA On': Today(),
            'FSQA Review Completed By': {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                    Department: "",
                    Claims: "i:0#.f|membership|" & varCurUser.Email,
                    DisplayName: varCurUser.FullName,
                    Email: varCurUser.Email,
                    JobTitle: "",
                    Picture: ""
                }
            }
        )
      )
    )
     
  • BCLS776 Profile Picture
    8,988 Super User 2025 Season 1 on at
    LookUp inside Patch inside ForAll only updating the first record
    Further to Warren's answer, a ForAll() using a gallery's AllItems property will frequently operate on only the first 100 records, and certainly no more than the row limit for the app. For as many records as you are updating, consider doing some sort of batch update or use Power Automate (it can handle 5000 rows at a time).
     
    Hope that helps,
    Bryan
  • WarrenBelz Profile Picture
    146,587 Most Valuable Professional on at
    LookUp inside Patch inside ForAll only updating the first record
    Hi TYSCC,
     
    You need to refer to the record as below - also this format is far more efficient.
    Patch(
       'Master Sanitation List',
       ForAll(
          Gallery1.AllItems As _Data,
          {
             ID: _Data.ID,
             'Reviewed by FSQA': "Yes",
             'Reviewed by FSQA On': Today(),
             'FSQA Review Completed By': 
             {
                Department: "",
                Claims: "i:0#.f|membership|" & varCurUser.Email,
                DisplayName: varCurUser.FullName,
                Email: varCurUser.Email,
                JobTitle: "",
                Picture: ""
             }
          }
       )
    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,587 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard