April 29, 2024

SamTech 365

PowerPlatform, Power Apps, Power Automate, PVA, SharePoint, C#, .Net, SQL, Azure News, Tips ….etc

PowerApps Patch vs SubmitForm

A recurring question, should I use Patch or SubmitForm function to save my data from PowerApps to SharePoint (or any data source).

Well, both functions are useful and can be used to send your data to the backend.

However, there are some differences between them, and more importantly, preferences to use one instead of the other.

Patch

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

 

Patch is a great function which allows you full control on the data you are submitting.

  • You can use formatted values (lower, upper case, custom format),
  • You can use function in addition to the values, e.g. Concat(“Item-” & txtTitle.Text).

Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ]) Ref

  • DataSource – Required. The data source that contains the record that you want to modify or will contain the record that you want to create.
  • BaseRecord – Required. The record to modify or create. If the record came from a data source, the record is found and modified. If the result of Defaults is used, a record is created.
  • ChangeRecord(s) – Required. One or more records that contain properties to modify in the BaseRecord. Change records are processed in order from the beginning of the argument list to the end, with later property values overriding earlier ones.

The most important aspect of Patch is flexibility, it allows you to submit part of the record instead of submitting the whole record to the back end, plus the flexibility of setting custom values part of the call to the Patch Function.

SubmitForm

SubmitForm( FormName )

This is a quick way of submitting a form to the back end,

If you don’t want to spend a lot of time in creating the form and aligning the different labels and text field, you can just use the form control, and make a call to SubmitForm, passing the actual form and that is it, your data is saved to the back end without too much hassle.

Verdict

I prefer to use Patch instead of SubmitForm for the flexibility given and the control of my data before submitting it.