From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer
Many times, a FileMaker solution will need to run a script automatically when a file is first opened. This is used to set a file up properly before the user starts getting down to business with it. This can include such steps as setting global fields, hiding the status area, going to the correct layout, performing start up finds / GTRR or maximizing the layout view to the users screen size ( to name just a few). On the flip side of the coin, you may need to run cleanup scripts when a file is closed by a user. This script normally includes closing down files that the solution opened via subscripts or relationships. That way the user doesn’t have stray FileMaker files open when they click the close box on a main file.
Fortunately, FileMaker has a way to set this up for you.
USING A SCRIPT TRIGGER
Under the File menu, you will see a command called File Options. Executing this menu command will bring up a dialog box that allows you to define a script to execute on file open and/or on file close. In FileMaker 10 and above, this is done via script triggers in the associated tab panel.
PREVIOUS TO FILEMAKER 10
Under the File menu, you will see a command called File Options. Executing this menu command will bring up a dialog box that allows you to define a script to execute on file open and/or on file close.
Here you can see I have setup a script called “Find Unposted” to activate when the database that I write my blog posts in is opened. This script will give me a found set of articles that I’ve started but need to finish and post to the appropriate site.
PLEASE NOTE: Back in the day, almost every FileMaker solution had multiple files, these would be the FileMaker 6 and earlier days (before multiple tables in a file).
When one FileMaker file needs to open another FileMaker file, the startup script in that remote file may end up being bypassed. This can happen when the files are linked via a relationship, a value list or via the Perform Script [ external ] script step.
One way to protect yourself is to make sure all files that may be called upon are opened when one of the files is first opened. In other words, the startup script in one file runs a master startup script in another file. It makes the opening process a little slower but it does provide the opportunity of an extra layer of protection that all startup process have been completed properly in all the files.
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.