FileMaker Scripting Best Practices and Conventions | DB Services

Emory Brown of DBServices weighs in with best scripting practices and conventions:

In application development, you want to build systems for the end user and it is important to keep the developer in mind when coding, so the application is usable behind the scenes as well as upfront. At DB Services we have several conventions that we consider to be some of the best practices to adhere to when developing. Let’s take a look.

Error Trapping

One thing that can drastically improve the user experience is user-friendly error trapping. Instead of no indication if an operation fails, giving the user a detailed error message of what went wrong in any given process can go a long way in building user trust. It also empowers the user to fix the problem themselves. Not only that, it can help the developer figure out what went wrong. The key is to be specific in the error message to the point the developer has enough information to know exactly which line of code failed, and on what record it occurred. One way we do this at DB Services is to also include the FileMaker error, after saying specifically what went wrong…

Proper Context

One of the easiest ways to incorporate error trapping is to run subscripts at the beginning of any script called from the interface to ensure the script cannot be run in an unintended context. The three most common things to check for are the following:

  1. Is the user in the correct mode?
  2. Are there records in the found set?
  3. Can the record be successfully committed?

Pay particular attention to the section of record locking.  He shows how to properly trap for that and how to keep from messing up data.  Important stuff, developers!  And while you are there, be sure to download their template database containing the sample code.

via FileMaker Scripting Best Practices and Conventions | DB Services.

Liked Liked
Need FileMaker Development Help? Or to purchase FileMaker Software?
Contact FM Pro Gurus for help