Tutorials/Power Apps/Bulk Patch Made Simple: Updating Gallery Items in One Go
Power Appsintermediate

Bulk Patch Made Simple: Updating Gallery Items in One Go

Learn how to use the lesser-known batch overload of the Patch function to write multiple SharePoint list items at once, drastically improving performance.

NA
Narmer Abader
@narmer · Published June 3, 2026

Working with large galleries often requires updating several records at once. The standard ForAll+Patch loop sends one request per row, which can feel slow when you have more than a handful of items. Power Apps includes a hidden gem—a batch overload of Patch—that lets you write all changes in a single call. This article walks through a realistic scenario and shows you how to apply the pattern in your own apps.

The Batch Pattern in a Nutshell

The single‑call version of Patch accepts three arguments:

  1. The data source (e.g., a SharePoint list).
  2. A table of primary‑key values (usually the ID column).
  3. A table of matching records that contain only the columns you want to update.

Instead of looping, Power Apps bundles all updates into one network request, giving you a noticeable speed improvement.

Scenario: Product Price Adjustment App

You work for a retail company that uses a SharePoint list named ProductCatalog to track inventory. The list has these columns:

  • ID (auto‑generated)
  • Title – product name (single line of text)
  • Price – current selling price (single line of text)

Staff need to review products in a gallery, edit the Price field for several items, and save all changes at once.

Sample Data

IDTitlePrice
1Widget A19.99
2Widget B24.99
3Widget C14.99
4Widget D29.99

Building the App

Add the ProductCatalog datasource to your app. Insert a Vertical Gallery and set its Items property to:

powerfxItems of gallery
ProductCatalog

Inside the gallery, add a Label to show the product name:

powerfxText property of label
ThisItem.Title

Add a Text Input control where the user can edit the price. Set its Default property to the current value stored in the list:

powerfxDefault of text input
ThisItem.Price

3. Create a Save Button

Below the gallery place a Save button. We will write all changes to SharePoint when the user clicks it.

The strategy:

  • Build a collection of only the items whose price has actually changed.
  • Compare the list value (converted to text to avoid null issues) with the current text input value.
  • Use the batch Patch to write the updates.
powerfxOnSelect of SaveButton (without error handling)
ClearCollect(
  colPriceUpdates,
  ForAll(
      Filter(
          galProducts.AllItems,
          Text(Price) <> txtPrice.Text
      ),
      { ID: ThisRecord.ID, Price: txtPrice.Text }
  )
);
Patch(
  ProductCatalog,
  colPriceUpdates.ID,
  colPriceUpdates
);
Notify(
  CountRows(colPriceUpdates) & " price(s) updated successfully",
  NotificationType.Success
);
Reset(galProducts)

Explanation:

  • ClearCollect(...colPriceUpdates...) creates a table of only the edited rows.
  • Filter(galProducts.AllItems, Text(Price) <> txtPrice.Text) keeps rows where the text input differs from the SharePoint value. Text() converts null to an empty string so the comparison works reliably.
  • Patch(ProductCatalog, colPriceUpdates.ID, colPriceUpdates) applies all updates in one call. The second argument is a table of IDs (each row has one column ID). The third argument is the table of matching records.
  • After the call the gallery is reset so it refreshes from the datasource.

4. Add Proper Error Handling

A real app should handle failures gracefully: check if any rows changed, catch backend errors, and show meaningful messages.

powerfxOnSelect of SaveButton with error handling
ClearCollect(
  colPriceUpdates,
  ForAll(
      Filter(
          galProducts.AllItems,
          Text(Price) <> txtPrice.Text
      ),
      { ID: ThisRecord.ID, Price: txtPrice.Text }
  )
);
If(
  !IsEmpty(colPriceUpdates),
  If(
      IsError(
          Patch(
              ProductCatalog,
              colPriceUpdates.ID,
              colPriceUpdates
          )
      ),
      Notify("Update failed – please try again", NotificationType.Error),
      Notify(
          CountRows(colPriceUpdates) & " price(s) updated",
          NotificationType.Success
      )
  ),
  Notify("No prices were changed", NotificationType.Error)
);
Reset(galProducts)

5. Let Users Cancel Edits

Provide a Cancel button that reverts all text inputs back to the original list values. The trick is to toggle a variable that is bound to the Reset property of each text input.

Place a Cancel button beside the Save button. Set its OnSelect to:

powerfxOnSelect of CancelButton
Set(gblResetInputs, true);
Set(gblResetInputs, false);
Reset(galProducts)

Then, back in the gallery, select the text input and set its Reset property to:

powerfxReset property of text input
gblResetInputs

When the cancel button is clicked the variable pulses truefalse, which triggers a reset of the text input to its Default value (the original SharePoint price). The Reset(galProducts) call scrolls the gallery back to the top if any scrolling had occurred.

Performance and Delegation Notes

  • Why it’s faster: Writing N items with ForAll sends N separate HTTP requests to SharePoint (or other datasource). The batch Patch sends a single request containing all changes. The saving becomes significant above 5–10 items.

  • Delegation: The Filter inside ClearCollect uses the AllItems property of the gallery. When the datasource is SharePoint, AllItems returns all records (subject to the 500‑item gallery limit). If your list grows beyond 2000 items, consider using Filter directly on the data source instead of on AllItems to stay within delegation limits.

  • Other datasources: This overload works with any datasource that supports updating multiple records in one operation (e.g., Dataverse, SharePoint). For SQL Server you may need a different approach because the current batch Patch is not supported for SQL tables.

Common Pitfalls

MistakeSolution
Forgetting Text() when comparing valuesWrap the SharePoint column with Text() to handle null.
Omitting ID from the updates tableThe batch Patch uses the second argument (IDs) to locate records. You can leave ID out of the third argument, but including it does no harm.
Using $"{}" inside code that will be passed as a template literalUse the & concatenation operator (e.g., "Updated " & CountRows(col) & " rows").
Not resetting the gallery after saveWithout Reset(), the outputs may still show the old values until a manual refresh.

Final Recommendation

The batch overload of Patch is one of the simplest performance wins you can apply to a Power Apps gallery. It reduces network chatter, makes the UI feel snappier, and the code stays readable. Next time you need to write multiple edits, skip the ForAll and reach for the table‑based variant.

References