Revert function
Applies to: Canvas apps
Refreshes and clears errors for the records of a data source.
Description
The Revert function refreshes an entire data source or a single record in that data source. You'll see changes that other users made.
For the records reverted, Revert also clears any errors from the table that the Errors function returned.
If the Errors function reports a conflict after a Patch or other data operation, Revert the record to start with the conflicting version and reapply the change.
Revert has no return value. You can use it only in a behavior formula.
Syntax
Revert( DataSource [, Record ] )
- DataSource – Required. The data source that you want to revert.
- Record - Optional. The record that you want to revert. If you don't specify a record, the entire data source is reverted.
Example
In this example, you'll revert the data source named IceCream, which starts with the data in this table:
A user on another device changes the Quantity property of the Strawberry record to 400. At about the same time, you change the same property of the same record to 500, not knowing about the other change.
You use the Patch function to update the record:
Patch( IceCream, LookUp( IceCream, Flavor = "Strawberry" ), { Quantity: 500 } )
You check the Errors table and find an error:
Record | Column | Message | Error |
---|---|---|---|
{ ID: 1, Flavor: "Strawberry", Quantity: 300 } | blank | "The record you are trying to modify has been modified by another user. Please revert the record and try again." | ErrorKind.Conflict |
Based on the Error column, you have a Reload button for which the OnSelect property to set to this formula:
Revert( IceCream, LookUp( IceCream, Flavor = "Strawberry" ) )
After you select the Reload button, the Errors table is empty, and the new value for Strawberry has been loaded:
You reapply your change on top of the previous change, and your change succeed because the conflict has been resolved.