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
Highlighted
Super User
Super User

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
Highlighted
Continued Contributor
Continued Contributor

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

Highlighted
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
Continued Contributor
Continued Contributor

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

Highlighted
Super User
Super User

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

Highlighted
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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,065)