Setting up script triggers
You can set up a script trigger to specify that a script runs when an event occurs. For example, you can use a script trigger to run a script that automatically enters data in fields based on what is entered in another field.
An important aspect of a script trigger is when the script runs in relation to the triggering event. Some script triggers run the script before an event is processed. Other script triggers run the script after an event is processed. For example, you could use the OnObjectEnter script trigger to run a script after a field is entered. (The field is the object; entering the field is the event.)
Script triggers can be activated by user actions or by scripts. For example, you could use the OnObjectEnter script trigger to activate a script to run when a field is entered either by a user clicking it or by a Go to Object script step.
You can set up a script trigger to activate:
 •
 •
 •
To see which layout objects and layouts have script triggers assigned to them, in Layout mode, choose View menu > Show > Script Triggers.
The following script triggers are available:
 
Before event
After event
Layout
Timing of script triggers
When multiple script triggers are activated by the same action, the script triggers activate in the following relative order:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
Notes
 •
Scripts that are run by script triggers use existing privileges. Unless a script is defined to run with full privileges, the script runs using the user’s privileges.
 •
In Instant Web Publishing and Custom Web Publishing, script triggers can only be activated by a script and not by direct user interaction. For example, if a user tabs into a field that has an OnObjectEnter script trigger, the trigger will not activate. If a script step causes focus to move into that field, the script trigger will activate.
 •
Some script triggers allow for the activating command or event to be canceled if the script executed by the script trigger returns a False value. When a command or event is canceled this way, the error code is set to 20. See Get(LastError) function for more information. If the script executed by the OnLastWindowClose script trigger returns a False value, then the file will not close.
 •
The OnFirstWindowOpen and OnWindowOpen script triggers display in the Script Debugger when a script is set to run on file open; the OnLastWindowClose and OnWindowClose script triggers display in the Script Debugger when a script is set to run on file close.
 •
 •
Mac OS: Command key combinations do not activate script triggers.
Related topics 
Debugging scripts (FileMaker Pro Advanced)
Using the Data Viewer (FileMaker Pro Advanced)
Topics in this section
Setting script triggers for layouts
Setting script triggers for objects
Changing object data without activating script triggers