You’ve been driving your car and it’s acting funny. You keep hearing a strange noise under the hood. You take the car to your mechanic and tell him all about it. However, when you try to show him, the noise is gone. We’ve all been there. Luckily, most modern cars now have the ability to plug in and dump diagnostic logs for the mechanic to review.
As a FileMaker developer, you've probably experienced similar scenarios. Your client calls you up and tells you there’s something wrong with the application. However, they can't seem to reproduce the problem when you're looking. Don’t you wish you could just plug in and see what was going on? Say hello to the Set Error Logging script step in FileMaker 18!
This new script step allows you to simply turn on error logging and capture all of the application’s errors in a log file. This can be set up in an
By default, the script logs the following information:
2. Database session number
4. Account name
5. Script name and script index (the script's position in Script Workspace)
6. Step name and line number within the script
7. Error code
This is already very useful information. However, sometimes it may not be enough and you may need more information about the context at the time the script was running. You can add as a parameter any information that can be calculated at the time of the error. In the case of this example, I added a parameter "Record:" & Sta__Staff::__id and "FoundCount:" & Get ( FoundCount ) for the custom debug info. The resulting error looks like this:
This tells us that upon running the script, “Toggle Slider for all records or found set” an error was triggered as the Go to Object step failed with an error 116. Following, you see “Record:" followed by no information. This is because there was a found count of 0 at the time and therefore no Staff ID to be found. This information can go a long way into troubleshooting issues with your FileMaker solutions.
With the addition of some of FileMaker’s other new features, you can go further and create a debugging system that automatically informs you of problems by sending email alerts or writing these errors to a log table within your system. You can check for the presence of the ScriptErrors.log file with the “Get File Exists” step. If the file is there, you can open it and read the data using “Open Data File” and “Read from Data file”. You can even then delete the file using the “Delete File” step.
BEFORE YOU START LOGGING
There are a few important caveats for working with the ScriptErrors.log.
1. FileMaker locks down the file the moment it's created. You can open the file and read the data, but any other actions taken by script steps on that file will fail. If you wish to open it or delete it with FileMaker, you will need to turn off set error logging first. This releases the file for the next actions. At this time, you can open and read the file. After doing this, don’t forget to run the Close Data File step. You can now delete the file or leave it in place. If you leave the file, the next time error logging is turned on, it will begin to append the data to this file.
2. If you've turned Error Logging on and it creates the file, you may read the file directly by opening it directly on your computer. If error logging was not turned off, FileMaker will continue to append data, even to the open file. However, should you delete this file while logging is still on, FileMaker will not create a new file in its place. Instead, it will continue to append data to the file in the trash. If you move the file out of the trash, you can open it and see that data has been added. It's important to turn data logging off and then delete/move the log file if you wish to have FileMaker create a new error log.
3. This function only works in FileMaker Pro 18 Advanced and FileMaker Go 18. We'll have to see if FileMaker, Inc. will eventually add the capability to WebDirect and Server.
There you have it! A pretty cool script step to help you manage and troubleshoot errors within your applications.
And another great feature that makes FileMaker the leading Workplace Innovation Platform. Join our mailing list to keep up with the new product features, like the new import interface and calculation functions in FileMaker 18.