Set Error Capture

Suppresses or enables normal alert messages displayed by FileMaker clients.

Options 

  • On suppresses FileMaker Pro alert messages and some dialog boxes. If the error result is 100 or 803, then certain standard file dialog boxes are suppressed, such as the Open File dialog box.
  • Off reenables the alert messages.

Compatibility 

Product Supported
FileMaker Pro Yes
FileMaker Go Yes
FileMaker WebDirect Yes
FileMaker Server Partial
FileMaker Cloud products Partial
FileMaker Data API Partial
Custom Web Publishing Partial

Originated in version 

6.0 or earlier

Description 

Use this script step to suppress normal alert messages displayed by FileMaker clients that are caused by subsequent script steps so that your script can handle errors instead. It is important that you anticipate as many problems as possible and include clear instructions for what to do for an error condition.

By using Get(LastError) function with certain control script steps, you can check whether the previous script step returned an error and take the appropriate action.

Notes 

  • Use Get (LastError) immediately after the script step you intend to test; a successful intervening step may clear the error code you were intending to capture. See FileMaker error codes.
  • When Set Error Capture is used in a script that contains a sub-script, errors from the sub-script are captured as well.
  • Server-side scripts and scripts performed via Custom Web Publishing or the FileMaker Data API always run as if Set Error Capture were set to On. See About running scripts on FileMaker Server and FileMaker Cloud products.

Example 1 

Performs a find and suppresses the error dialog box if no records were found.

Copy
Set Error Capture [On]
Perform Find [Restore]

Example 2 

Performs a find. If no errors occur, sorts records. If no find criteria were specified, shows all records. If no records match the find request, displays a custom dialog box.

Copy
Set Error Capture [On]
Perform Find [Restore]
If [Get ( LastError ) = 0]
Sort Records [Restore; With dialog: Off]
Else If [Get ( LastError ) = 400]
Show All Records
Else If [Get ( LastError ) = 401]
Show Custom Dialog ["Find"; "No records were found."]
End If