Database Reference
In-Depth Information
Object triggers are tied to a single layout object (like a field, portal, Tab Control, or web
viewer). These triggers fire when you interact with that object in some way, like editing
the data in a field, or switching to a different tab panel.
Timer triggers are attached to a specific window and set to run at a specific time inter-
val.
Some triggers fire before their controlling action, and some fire afterward. And you can ap-
ply more than one trigger to a single layout or object, so it's critical to understand when they
fire and in which order. So take care when you start to apply triggers. They're simple to ap-
ply but can be tricky to predict, and tricky to troubleshoot, unless you understand all their be-
haviors. You'll start this section by applying a simple script trigger and then you'll learn how
each trigger works. You'll see other examples of script triggers in later scripting chapters.
Creating a Simple Script Trigger
Since you'd only view the “Invoices with Balance Due” layout when you want to find un-
paid invoices, it makes perfect sense to run the Find Unpaid Invoices script every time you
switch to that layout. You'll use an OnLayoutEnter script trigger to get the job done:
1. Switch to your “Invoices with Balance Due” layout and then go to Layout mode .
You're creating a layout trigger (that fires when you switch to the “Invoices with Bal-
ance Due” layout), so you need to be on that layout.
2. Choose Layouts Layout Setup and then switch to the Script Triggers tab .
This tab is where you configure triggers for the layout. You can see it in Figure 11-20 .
3. In the list, turn on the OnLayoutEnter checkbox .
The Specify Script window appears.
4. Select the Find Unpaid Invoices script and then click OK .
In the list, the OnLayoutEnter trigger is highlighted, and, in the Script column, the
Find Unpaid Invoices script shows. You can also see the script's name beside the
Select button in the Script Trigger Properties section of the window.
5. Select the Browse and Preview checkboxes and, if necessary, deselect the Find
checkbox .
Since it does a find, this script makes sense only in Browse mode and Preview mode,
so you want it to trigger only in those cases.
6. Click OK .
Search WWH ::




Custom Search