I have created a 3 forms that uses a Patch formula to submit all of the fields to a SharePoint List. Then, I've used a variable formula to retrieve the list item data back into PowerApps to update. How can I create Patch method that will update the list item in SharePoint rather than create a new list item (like it is doing now)?
Current patch formula:
Patch('Assessment Form',Defaults('Assessment Form'),OutcomeCourseForm_1.Updates, AssessmentForm_1.Updates);Notify("Your Course Assessment has been updated.",NotificationType.Success)
Solved! Go to Solution.
Hi @Anonymous
@OneThing is right you need to change the Defaults function that is only used to create a new item.
Instead of First(Filter()) like @OneThing suggests, I would rather use a lookup. Assuming your variable that stores the item to update is named myItem, yur formula should look like :
Patch('Assessment Form',LookUp('Assessment Form',ID=myItem.ID),OutcomeCourseForm_1.Updates, AssessmentForm_1.Updates);Notify("Your Course Assessment has been updated.",NotificationType.Success)
There are 2 ways to update an item using Patch :
Théo
Hi There,
Your Patch Command Uses the Defaults() function, This creates new entries as per the documentation:
"Use Patch with the Defaults function to create records. Use this behavior to build a single screen for both creating and editing records. For example, this formula creates a record for a customer named Contoso:"
Remove this and you should have more luck.
See the Patch Documentation for more information.
Thanks,
Nicky
@OneThing Thanks for the post, but that didnt work. The data did not update.
Hi @Anonymous
Remove the Default() Function was probably not the best expression to use. You need to replace the Default() with an identifying formula for the entry you want to update. The Blue Section below shows the required information.
Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ])
In this case you would need to replace Defaults() with something like:
First( Filter( 'Assessment Form', Title = "TitleName" ))
Thanks,
Nicky
Hi @Anonymous
@OneThing is right you need to change the Defaults function that is only used to create a new item.
Instead of First(Filter()) like @OneThing suggests, I would rather use a lookup. Assuming your variable that stores the item to update is named myItem, yur formula should look like :
Patch('Assessment Form',LookUp('Assessment Form',ID=myItem.ID),OutcomeCourseForm_1.Updates, AssessmentForm_1.Updates);Notify("Your Course Assessment has been updated.",NotificationType.Success)
There are 2 ways to update an item using Patch :
Théo
@tchin-nin Using the lookup feature worked! Since I'm using variables (bold)...
Patch('Assessment Form',LookUp('Assessment Form', ID=AssessmentEdit.ID),OutcomeCourseForm_1.Updates, AssessmentForm_1.Updates, AssessmentForm_3.Updates);Notify("Your Course Assessment has been updated.",NotificationType.Success)
Thanks!!
User | Count |
---|---|
143 | |
142 | |
78 | |
75 | |
72 |
User | Count |
---|---|
227 | |
144 | |
78 | |
62 | |
58 |