cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Need to submit updated data to SharePoint from PowerApps

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)

1 ACCEPTED SOLUTION

Accepted Solutions
tchin-nin
Level 10

Re: Need to submit updated data to SharePoint from PowerApps

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 :

  • Use the second parameter to specify the item (what I did before using the LookUp formula)
  • Having a primary key in the pushed updates like : Patch(SPList,{ID:54, Title:"Hello World"})

Théo

View solution in original post

5 REPLIES 5
OneThing
Level 8

Re: Need to submit updated data to SharePoint from PowerApps

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

Anonymous
Not applicable

Re: Need to submit updated data to SharePoint from PowerApps

@OneThing Thanks for the post, but that didnt work. The data did not update.

Highlighted
OneThing
Level 8

Re: Need to submit updated data to SharePoint from PowerApps

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, … ])

  • 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.

In this case you would need to replace Defaults() with something like:

First( Filter( 'Assessment Form', Title = "TitleName" ))

Thanks,
Nicky

tchin-nin
Level 10

Re: Need to submit updated data to SharePoint from PowerApps

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 :

  • Use the second parameter to specify the item (what I did before using the LookUp formula)
  • Having a primary key in the pushed updates like : Patch(SPList,{ID:54, Title:"Hello World"})

Théo

View solution in original post

Anonymous
Not applicable

Re: Need to submit updated data to SharePoint from PowerApps

@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!!

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 70 members 3,428 guests
Recent signins:
Please welcome our newest community members: