Database Reference
In-Depth Information
The Get(LastError) Function
When error capture is on, FileMaker doesn't show error messages. But it still knows which
error occurred and gives you the chance to ask about it if you're interested. The script in Fig-
ure 17-16 , for example, isn't interested. It doesn't ask if an error occurred at all. Instead, it
just checks to see if the find worked by counting the records in the found set.
But sometimes you can use such error information within your script, much like any other
value, to trigger other script steps. To check an error, use the Get(LastError) function to
find out what happened. This function returns an error code , which is always a number. If
there was no error in the previous step, Get(LastError) returns a zero. In other words, it
doesn't return the number of the last error that occurred. Instead, it returns the error number
for the last step that ran. If your Get(LastError) step can't come right after the issue you're
checking (maybe you have to check a couple of steps for errors before your branching starts),
you can store the error code in a variable and then check its contents later in the script.
In FileMaker, just about everything that could possibly go wrong has its own error number or
code. This feature gives you a lot of flexibility, but it also makes it a real pain to figure out
which errors you should check for. A complete list of error codes is found in Appendix C .
Luckily, most of these errors are pretty obscure, and chances are you'll never have to worry
about them. Here's a list of the more common error numbers you should take note of:
Error 9, 200-217, 723-725 . Assorted security-related errors (see Chapter 18 ) .
Error 112 . Window is missing (you get this error if you try to select, close, or move/res-
ize a window that doesn't exist).
Error 301 . Record is in use by another user (you get this error when a script tries to
modify a record that's locked in another window or by another user).
Error 400 . Find criteria are empty (if you let users enter find criteria during a script, the
Perform Script step gets this error if they don't enter anything).
Error 401 . No records match this request (this is the actual error that happens when no
records are found; most people choose to check Get(FoundCount) instead since it's easi-
er to understand).
Errors 500-507 . Assorted field validation errors (you get these errors when you try to
modify a field in a way that violates its validation setting and it's set to “always” valid-
ate).
Errors 718 and 719 . XML processing errors (see Chapter 21 ) .
Search WWH ::




Custom Search