cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Variable not updating

Hi All,

 

The code below is set on my edit form submit button.  I have placed labels on the form for testing with the text set to each variable so I can see what the variable is set to.  I noticed that after creating the first record the variables do not update after clicking the submit button.  If I go back into that first record, edit and submit again then they get updated.  Once the variables are set all records after the first seem to work as I would like.  These variables capture info entered on the previous record and used for calculations on the new record. 

 

SubmitForm(EditForm1);UpdateContext({varTrailerGal:DataCardValue34.Text}); UpdateContext({varCumGall:DataCardValue30.Text});UpdateContext({varMeter:DataCardValue28.Text})

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Variable not updating

A much simpler way is to use the LastSubmit function.

In the Onsuccess property of the Editform put;

Set(varRecords,EditForm1.LastSubmit)

 

Then you can access the various fields entered on the form as;

 

If datacaradvalue28 contains ID;

varRecords.ID

 

If datacaradvalue30 contains Firstname;

varRecords.FirstName

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: Variable not updating

A much simpler way is to use the LastSubmit function.

In the Onsuccess property of the Editform put;

Set(varRecords,EditForm1.LastSubmit)

 

Then you can access the various fields entered on the form as;

 

If datacaradvalue28 contains ID;

varRecords.ID

 

If datacaradvalue30 contains Firstname;

varRecords.FirstName

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

View solution in original post

Highlighted
Memorable Member
Memorable Member

Re: Variable not updating

Hi @burliad ,

For the Requirement,
as per my understanding, I can suggest te below ways to resolve your issue.

I think the variables you are setting you are assigning the Datacard values to them, I don't think so that is good practice.

So here is the solution for your Issue.

Select the From and Set the OnSuccess properties.
Like Below. (Note -  if you are using the below variable on the same screen then you can use like that)

 

UpdateContext({varTrailerGal:LastSubmit.ColumnName}); UpdateContext({varCumGall:LastSubmit.ColumnName});UpdateContext({varMeter:LastSubmit.ColumnName})

 


But if you are using these variables on different screens. then use like below.

 

Set(varTrailerGal:LastSubmit.ColumnName); Set(varCumGall:LastSubmit.ColumnName);Set(varMeter:LastSubmit.ColumnName)

 

Or Set(SubmitedValue , LastSubmit(Form1);
Hope this will help you to resolve your issue.

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."



Highlighted
Helper II
Helper II

Re: Variable not updating

Thank you both for your quick replies.  I didn't know about the LastSubmit or the OnSuccess of the EditForm.  I ended up using the code below on the OnSuccess.  Thank you both again so much!

 

Set(varRecords,EditForm1.LastSubmit);UpdateContext({varMeter:varRecords.meter_total});UpdateContext({varCumGall:varRecords.cum_gallons});UpdateContext({varTrailerGal:varRecords.trailer_remain_gal});Back()

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,863)