Set Revert Transaction on Error
Controls whether transactions are immediately reverted when an error occurs.
See also
Options
-
On automatically reverts transactions as soon as certain errors occur. This is the default behavior when this script step isn't used.
-
Off allows steps within transactions to continue even after certain errors occur.
Compatibility
Product | Supported |
FileMaker Pro | Yes |
FileMaker Go | Yes |
FileMaker WebDirect | Yes |
FileMaker Server | Yes |
FileMaker Cloud | Yes |
FileMaker Data API | Yes |
Custom Web Publishing | Yes |
Originated in version
21.1.1
Description
When this script step is On, if a script step within a transaction returns an error because it can't create, update, or delete data as expected, the transaction is automatically reverted, behaving the same as when the Revert Transaction script step is performed without a condition. These types of errors automatically revert transactions:
-
A change to a field, which is set to always validate, that doesn't match the field's validation options
-
Privilege errors such as no field access, no record access, and no table access
Turn this script step Off to add your own error handling within transactions. For example, after an error occurs that would otherwise revert the transaction, your script can attempt to address the error, then retry the operation to avoid reverting the entire transaction.
When Off, this script step also helps while debugging a transaction in Script Debugger. Because an error doesn't automatically revert the transaction, you can set the next step wherever you want, including within the transaction, which would otherwise not be allowed.
Notes
-
To get the current state of Set Revert Transaction on Error, use the Get(RevertTransactionOnErrorState) function.
-
If set to Off, Set Revert Transaction on Error remains off for as long as the current script and any sub-scripts are running, unless changed. When the current script ends, the state returns to On.
Example 1
Opens a transaction and tries to set the Text field and the Number field, which has validation enabled for numeric-only data. Set Field for Text succeeds. Set Field for Number fails validation and returns an error, but the transaction doesn't automatically revert. Instead, the custom dialog is displayed, then the transaction is committed, changing only the Text field.
Set Revert Transaction on Error [ Off ]
Open Transaction [ ]
Set Field [ Table::Text ; "Novel" ]
Set Field [ Table::Number ; "It was a dark and..." ]
If [ Get ( LastError ) > 0 ]
Show Custom Dialog [ "Oops, something went wrong with Number." ]
End If
Commit Transaction