In FileMaker 18, we received a new script step called Error Logging. When this script step is used, any errors that are generated from the running script are pulled into a log for review.

Parameters for the error logging script step in FileMaker 18

The step allows for two parameters. The first is whether to turn the logging on or off. Once error logging is turned on, any time a script in the current file generates an error, a file called ScriptsError.log will be created or appended to for as long as the file is open or if the script step is called again with the login set to off.

The error log captures the following:

The second parameter, Custom Debug Info, is optional. It’s set by clicking the gear icon in the script step. This will open up a calculation dialogue whose result will be appended to any entries created. This can be useful to capture other information not handled by the error log. I like to use a custom function called ErrorData which looks like so:

Here’s what the output looks like when opened using the console:

Output of the error logging script step in FileMaker 18

The ScriptErrors.log file lives in the user’s documents’ folder and is accessible via the new data file script steps by providing the filepath:

Get( DocumentsPath ) & “ScriptErrors.log”

Be advised that the file will be locked and inaccessible by the data file script steps until the Set Error Logging script step is turned off, so it’s a good idea to turn off error logging once you have executed the portions of a script you anticipate could generate errors.

Also note that the error logging state is specific to the file it was called in, so if you are calling a script that generates an error from another file with a parent script where you have error logging turned on, it will not create a new log entry. You have to turn error logging on a per file basis. FileMaker has a helpful tutorial video here that nicely covers the basics.

This tool gives us more options on how we can handle errors in an app, which means at the end of the day it’s a better overall experience for users and developers alike. I can’t wait to see how the community utilizes the new step. And, as always—Happy FileMaking folks!

One comment

  1. This is awesome, I never thought to include all extra Get functions as the custom debug info but I can see this coming in handy. It got me thinking whether you could use the design functions to get a list of all non calc/summary fields in the current context, and then use a while loop to build up a JSON object of field names & their current values, you could use Evaluate to do this so that at any point in the error you know the values of every field?

    cheers!

    Posted by Daniel Wood on June 20, 2019. Reply

Leave a comment

Your email address will not be published. Required fields are marked *