15 April 2022
Power Apps - Patch function
Technical article about Power Apps - Patch function
functions
patch
pills
save
update
1 min read
Technical article about Power Apps - Patch function
Hello, new Post Today. We’re going to understand how to use Patch function with SharePoint list. For this Example I used a “Task List” who contains text , choose , lookup and numeric columns.
Let’s see “Patch” Function.
Syntax
Patch( DataSource, BaseRecord , ChangeRecord1 ,_ChangeRecord_2,…)
Parameters:
Pills:
Here our task list:
Create new record:
Patch(
Tasks,
Defaults(Tasks),
{
Title: "New Task",
Description: "Our task descriptions",
Status: {Value: "New"},
Project: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: 1,
Value: "Project 1"
},
ProjectID:1000
}
)
Key points:
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: 1,
Value: "Project 1"
}
That’s all! If we want to update an existing record? You must get it and pass to patch function instead Defaults(). In this case, I used Lookup function to retrieve record to update:
LookUp(Tasks,ID=4)
So, complete code is:
Patch(
Tasks,
LookUp(Tasks,ID=4),
{
Title: "Old Task",
Description: "Our task descriptions",
Status: {Value: "New"},
Project: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: 1,
Value: "Project 1"
},
ProjectID:2000
}
)
This is the official link of patch function.
I hope this post should help you.