Patch, update and update if functions

Loading

Patch function in power apps :– patch function will be used to create a new record or modify an existing record in a Data source . patch will also merges records outside of Data source.

Use the patch function to modify records in complex situations, such as when you do updates that require no user interactions or use forms that span multiple screens.

1.The syntax for creating a new record in a data source

Syntax :- Patch(Data Source, Defaults(Data Source), {Record})

2.The syntax for updating a record in data source

Syntax :- Patch(Data Source, Item, {Record})

Here i am using a data source “Hard” .

1.The below formula in the image is used to create a new record in data source .

here i have used a choice column for which the patch function syntax is different as given below

Syntax :- choice column

{Value: "choice value"}

formula : patch(Hard,Defaults(Hard),{Title:txttitle.Tet,technology:txttech.Text,’status’:(Value:”txtstatus”)})

The result will be shown in below image where the new item is stored in the gallery at the bottom.

2. The below formula in the image is used to modify a record which is existing already in the data source

Patch(Hard,First(Filter(Hard,Title=”Microsoft”)),{technology:”outlook”})

Here i have also add a function to sort the gallery in items property to see the edited data in descending order. formula :- Sort(Hard,Modified,Descending)

Here we can see the result for modifying an record where i have modified one drive as outlook

Update function in power apps:– Use the Update function to replace an entire record in a data source.

here i am updating a record in share point data source. I have added the following formula to a button.

Formula :- Update(Hard,First(Filter(Hard,Title=”microsoft”)),{Title:”sony”,technology:”mobiles”})

Update if function in power apps:- Use the Update If function to modify one or more values in one or more records that match one or more conditions. The condition can be any formula that results in a true or false and can reference columns of the data source by name. The function evaluates the condition for each record and modifies any record for which the result is true.

Here i am going to update a record “google”.

Formula :- updateif(Hard,Title=”google”,{Title:”sony”,technology:”mobiles”})

The result when we have performed the update if function will be shown below.

here i have updated a record “google” with “sony” as we seen in image where the google record is updated as sony

Leave a Reply

Your email address will not be published. Required fields are marked *