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.
Some script triggers run the script before an event is processed by the database engine. Other script triggers run the script after an event is processed by the database engine. 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:
•when a file is opened or closed, or the playback state changes for a media file. For information on how to do this, see
Setting file options.
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:
Trigger area | Script trigger | Before processing | After processing |
Object | | | X |
| X | |
| | X |
| X | |
| | X |
| X | |
| X | |
| | X |
Layout | | | X |
| X | |
| X | |
| X | |
| | X |
| X | |
| | X |
| | X |
| X | |
| | X |
| X | |
| | X |
File options | | | X |
| X | |
| | X |
| X | |
| | X |
Timing of script triggers
When multiple script triggers are activated by the same event, the script triggers execute in the following relative order:
1. OnFirstWindowOpen
2. OnWindowOpen
3. OnLayoutEnter
4. OnModeEnter
5. OnRecordLoad
6. OnLayoutSizeChange
7. OnViewChange
For the following script triggers, the order is controlled by the triggering event:
8. OnObjectEnter
9. OnObjectKeystroke
10. OnLayoutKeystroke
11. OnGestureTap
12. OnObjectAVPlayerChange
13. OnFileAVPlayerChange
14. OnExternalCommandReceived
15. OnPanelSwitch
16. OnObjectModify
17. OnObjectValidate
18. OnObjectSave
19. OnObjectExit
20. OnRecordCommit or OnRecordRevert
21. OnModeExit
22. OnLayoutExit
23. OnWindowClose
24. OnLastWindowClose
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 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 triggering 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.
•Windows: Alt and Ctrl key combinations do not activate script triggers.
•OS X: Command key combinations do not activate script triggers.
Related topics