Blog
Bug - What to do when setting a variable to Form.LastSubmit doesn't work
A recent update to Power Apps can cause formulas that set Form.LastSubmit to fail. This post summarises this bug and describes how to fix it.
What's the purpose of Form.LastSubmit?
The LastSubmit property enables us to retrieve the record that was last edited or added via a form control. This is crucial for obtaining server-generated values like the ID number of a new record.
What happens when setting a variable to Form.LastSubmit?
A common practice is
to store the LastSubmit value in a variable in the OnSuccess property of a form like so.
Set(varLastRecord,
Self.LastSubmit
)
As a result of this bug, it isn't possible to access any of the fields in the variable after calling Set. For example, if we enter 'varLastSubmit.' into the text property of a label, the Intellisense in the designer does not show any of the fields.
If we examine the variables pane in the designer,
notice how the left hand panel correctly shows the JSON of the LastSubmit record, whereas the body of the variable is blank.
Is it possible to set a variable to Form.LastSubmit?
To work around this bug, we might attempt to set the variable to the ID property of LastSubmit.
Set(varLastRecordID,
Self.LastSubmit.ID
)
Does using a context variable make any difference?
Using a context variable rather than a global variable makes no difference. The context variable also appears blank, as shown beneath.
How to resolve this bug
The cause of this bug is the new analysis engine, which is enabled by default for new apps.
To solve this problem, turn off the 'New analysis engine' option in the Updates> New section of the app settings.
Once we reload the designer, setting a variable to LastSubmit will work as expected. In the screenshot below, note how the LastSubmit details now appear in the body of the variables pane.
Conclusion
- Categories:
- bug
- Bug - How to fix problem with the advanced section of the properties pane appearing blank
- Bug - What to do when the Power Apps editor shows an empty grey screen
- Errors - What to do when creating an app with the 'start with data' feature fails
- Bug - Internal error in the AND/OR function Canceled Canceled
- Bug - OnStart property missing from designer - impossible to set OnStart formula
- SQL - How NOT to name database tables, columns, and objects