For a long time, FileMaker has provided a helpful message to interactive users when they bump into each other. Even though locked records are a source of frustration, they exist for a good reason. A user Bob might get a message that a record is already being edited by Jane.
However, this information hasn’t, until now, been available to developers when running scripted edits. Hooray for FileMaker 16 which now makes this possible! Starting with this release, when trapping for errors during record edits, we can collect and bubble up more useful error messages to our users. This is accomplished using the Get(LastExternalErrorDetail) function. The documentation states,
For operations that attempt to lock records already in use, returns the name and account of the user currently editing the record.
See the screen shot that demonstrates this new capability.
Notice that the User Name is returned first, followed by the Account Name inside parenthesis.
Here are a few things to keep in mind:
- Most script steps clear the error status found in Get(LastError), and the same is true of the new function. Two consecutive Set Variable steps to store away the error number and extended detail will not work. The completion of the first Set Variable step will clear the extended detail before the second step could read it. I’ve not settled on a best practice yet, but capturing both error number and detail in a single step using a Let() seems to work well.
- This capability appears to be a client-side feature of FM16. Initial testing with a version 16 client on a version 15 server worked fine.
- The Get(LastExternalErrorDetail) function has been around since FM6, but historically will return nothing unless you are utilizing ODBC. It seems that you could safely write code that will support both current FM15 deployed solutions and future FM16 upgrades.
- The error detail function is used by many other new functions as well in FM16. It might be confusing if there is a potential of either a record locking error or a cURL error emanating from the same Insert From URL step. I’ll probably be intentional about locking the record first and then utilizing cURL in a later step.
We’re looking forward to this and many of the other new features that were released this week. We’d like to hear from you if you find other creative approaches that utilize this feature.