cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AaronO
Helper I
Helper I

Patch Items in Sharepoint list after Submitting Form to different list

I have a form which is working properly to submit data via form into a SharePoint list.  My next task is to take the results of calculated fields in the SharePoint list within the submitted record and update another list using some logic that runs in the Power App.  My current thought is to just read the record and perform the calculations in some labels on the Power App screen then run a Patch to the second list with those results.  The problem is that I cannot get the values in the labels to update after the form submit.  Clicking on the gallery on the same screen updates the values just fine, so I don't know what process the gallery is using to refresh the screen that I can't access otherwise.

 

I don't have to use the labels to do the calculations, so if there's a better way to get the updated info, I'll take that solution also.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@AaronO 

Are you stating that you want to get a value from the record in SharePoint that has a calculated column in it that you want?

First I'd recommend doing the calculation in your app instead, but beyond that, once your form submits, In the OnSuccess action of the form you will have access to the LastSubmit record - that record will have what you are looking for.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@AaronO 

Are you stating that you want to get a value from the record in SharePoint that has a calculated column in it that you want?

First I'd recommend doing the calculation in your app instead, but beyond that, once your form submits, In the OnSuccess action of the form you will have access to the LastSubmit record - that record will have what you are looking for.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

@RandyHayes that is good advice.  It works, thank you.

 

I implemented it by adding this pattern to OnSuccess:

Set(VariableName,FormName.LastSubmit)

Then as my fields all reference that same variable, they refresh as expected. 

 

Why doesn't the app refresh the variable when setting the variable directly using the externally known record ID, but instead must be refreshed using LastSubmit?

RandyHayes
Super User
Super User

@AaronO 

Very good!

 

I'm not sure exactly what you're asking in your question - 

A variable never updates until you update it.  

When you submit a record, the datasource will update with the new record information as retrieved from the real datasource (note, a datasource in your app is an "in between" table of records that is filled automatically as needed by the app).

So, if you have a datasource (real one) with an ID of say 5 and you get that record into the app datasource (by whatever means - lookup, filter, etc.) then your local datasource has record ID 5.  If you submit a form for that record to update it, then once it is completed (in the OnSuccess action) your local datasource now has an updated record 5 in it.  If you set a variable to a lookup of that record After the submit, it will have the same updated information in it.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

Yes, you are correct.  To clarify, I am using a variable to store the record which is selected from the gallery by using Set(varRecord, ThisItem) in the gallery.  Since I'm just doing an update, I would expect the later command of Set(varRecord, Lookup('SourceTable',ID=varRecord.ID)) to use the existing ID loaded in the variable to go match to the same source record and update the variable with the new information from the table.  But it doesn't.

RandyHayes
Super User
Super User

@AaronO 

If you have that in the OnSuccess of the form, then it should work fine.  Although I would still rely on the ID of the form record.  i.e.   Set(varRecord, Lookup('SourceTable',ID=Self.LastSubmit.ID))

But as you can see with that...it's an extra trip through the datasource that is not needed, as the following is equivalent and faster:  Set(varRecord, Self.LastSubmit)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,266)