From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer
One thing that can happen in any search is that no matching records are found. In a regular user controlled search, the user gets the message and may decide to perform another search. In a script, the search may only be part of the overall operation. If the user decides to do a different search or cancel the search, the remaining script steps could cause harm to your database. For this reason, you will likely want to capture and branch the script in the cases that no matching records were found.
It is also possible that with no records found, all the records are in the omitted set and the user doesn’t realize this. Looking at a found set of zero records may give them they mistaken idea that all the records have been deleted!
I have seen this happen. I had a user that kept telling all the other users in the office that FileMaker was “crashing all the time.” When I sat with her in her cube to see this, she was running a script that occasionally found no matching records.
So what you want to do is provide some error capture to your script. When Set Error Capture script step is included in a script and is set to the ON position, the FileMaker pop up error dialog boxes to the user are suppressed while the script is running. You then can use the IF, ELSE and END IF scripts steps are part of your error handling routine.
So the above situation is a good place to put some error trapping in your script. For example, your script could look like ...
Set Error Capture [ ON ]
Perform Find [Restore, Replace Found Set ]
If [Get ( LastError ) =401
Show All Records
Instead of Get ( LastError ), you could also trap for the condition that no records are in the found set. Something like this, Get ( FoundCount ) < 1, would do the trick.
More info about the author and FileMaker in general, contact me at email@example.com.
© 2008 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.