Get(LastError)

Returns a number for the error that occurred in the execution of the most recently executed script step.

Format 

Get ( LastError )

Parameters 

None

Data type returned 

number

Originated in version 

6.0 or earlier

Description 

Use this function to detect and control the outcome of errors. See FileMaker error codes.

Notes 

  • macOS: In FileMaker Pro, if an error occurs while performing an AppleScript via the Perform AppleScript (macOS) script step, the AppleScript error code will be returned.

  • For ODBC imports and Execute SQL script steps, if an error occurs while performing a SQL query, returns FileMaker error 1408. For detailed information about the error, use the Get(LastErrorDetail) function. If there is no information about the error, returns FileMaker error 1409.

  • For working with ODBC data sources in the relationships graph, returns FileMaker error 1408.

  • Some script triggers allow for the activating command or event to be canceled if the script executed by the script trigger returns a False value. When a command or event is canceled this way, the error code is set to 20.

  • The following control script steps do not clear the last error condition reported by FileMaker Pro: If, Else, Else If, End If, Loop, Exit Loop If, End Loop, Exit Script, and Halt Script.

  • If an error condition already exists when the user cancels an action, the existing error condition is not cleared.

  • For actions that fail to connect to a host because the host's SSL certificate cannot be verified, this function returns an error code. For detailed information about the error, use the Get(LastErrorDetail) function.

  • To create a script that responds to errors without displaying alerts, use this function with the Set Error Capture script step with the On option.

  • To evaluate an error in a calculation expression, use the EvaluationError function.

Example 1 

Returns 0 when the most recent script step executed successfully.

Returns 401 when no records are found after the Perform Find script step has been executed.

For an example script, see Set Error Capture script step.