← Al Davies, 250 High Street

How to use Patch to save to a SharePoint list in Power Apps

Patch writes to a data source from a formula. To update an item, give Patch the list, the item to change, and the new values; to create an item, use Defaults as the second argument.

What does the Patch function do?

Patch changes or creates records in a data source. A SharePoint list is a data source, and each list item is a record. Patch updates only the fields you name and leaves the other fields alone.

Microsoft says to use Patch for complex cases, such as updates that need no user interaction or forms that span several screens. For simple changes, Microsoft points to the Edit form control. See our guide on Power Apps forms compared with list forms if you are not sure which fits.

How do you update an existing item?

Pass three things: the data source, the item to change, and a record with the new values. The item must trace back to the data source. You can get it from a gallery's Items property, a context variable, or a LookUp. Microsoft shows this pattern with a customer list:

`Patch( Customers, LookUp( Customers, Name = "Contoso" ), { Phone: "1-212-555-1234" } )`

Change records are processed from the start of the argument list to the end. If two records set the same field, the later value wins.

How do you create a new item?

Use the Defaults function to build a base record with default values, then add your values. Microsoft's example:

`Patch( Customers, Defaults( Customers ), { Name: "Contoso" } )`

The data source and the Defaults function must name the same source, or the new record is not created. Patch returns the record it made, which can include values the source created on its own, such as an ID. In Microsoft's ice cream example, the ID column is filled in by the data source.

Can Patch save many items at once?

Yes. Give Patch a table of base records and matching tables of changes. The number of records in each change table must equal the number of base records, or an error occurs. Microsoft's example updates two flavors in one call:

`Patch( IceCream, Table( { ID: 1, Flavor: "Chocolate", Quantity: 150 }, { ID: 2, Flavor: "Vanilla", Quantity: 200 } ), Table( { Quantity: 300 }, { Quantity: 400 } ) )`

To create several records, use Table( Defaults( IceCream ), Defaults( IceCream ) ) as the base. The result is a table with one record for each input record.

How do you handle Patch errors?

Saves can fail. Microsoft names three common causes: no connection to the data source, a record changed by someone else, and missing permission. Wrap Patch in IfError to catch a failure and show a message:

`IfError( Patch( IceCream, baseRecords, changeRecords ), Notify( "Some records failed to update: " & FirstError.Message, NotificationType.Error ) )`

For the conflict message, Microsoft advises calling Refresh on the data source and trying again. If the save fails for one person only, check that person's permission on the list first.

What about choice, lookup and person columns?

Microsoft's column examples are for Dataverse, and it states that SharePoint and SQL Server may need different record shapes. Check Microsoft's documentation for your data source before you copy a Dataverse pattern.

Advice from us: save one test item with a single changed column, then open the list and check the value. Our guides on lookup columns that do not show and reading a person column explain how those column types behave in a list.

Does a long list slow Patch down?

Microsoft says Patch is not subject to delegation, because it writes data instead of querying it. A delegation warning on a formula that uses Patch usually comes from the Filter, LookUp or ForAll part that picks the record.

If a warning appears, look at that part first. Our guide on the list view threshold covers the limit on the list side.

Want help with an app on a SharePoint list?

I am Al Davies at 250 High Street LLC. I build SharePoint and Power Automate trackers remotely for small teams. The first call is free. You can see past work in the portfolio.

FAQ

Should I use Patch or an Edit form?

Microsoft says to use an Edit form for simple changes. Use Patch for updates with no user input or forms that span several screens.

How do I create a new item with Patch?

Pass Defaults of the same data source as the base record, then your values in a change record.

Why does my Patch show a conflict error?

Someone or something changed the same record after your app read it. Microsoft advises calling Refresh and retrying.

Sources