Database Reference
In-Depth Information
Advanced Script Triggers
On Timer Scripts , you got an intro to using timers with the Install OnTimer Script step,
which lets you schedule a script to run repeatedly. Now you'll get the full Install OnTimer
story, and learn how the OnKeystroke trigger lets you respond to every keystroke your user
makes.
NOTE
These are power-user triggers that require a lot of expertise to use properly. They give you a lot of
power, but they're more complex than the script steps you've seen so far. Approach them with a
clear head and a fresh cup of coffee.
Install OnTimer Script
The Install OnTimer Script step has two options. First, you specify the script you want
to run (along with an optional script parameter). Then you specify the number of “Interval
seconds.” For instance, you can schedule your Find Unpaid Invoices script with an interval
of 10 seconds. If you then run the script with the Install OnTimer Script step, your
Find Unpaid Invoices script runs every 10 seconds forever.
Of course forever is a long time. How do you stop a timer like this? In two ways:
▪ Timers are associated with the window that was active when the timer was installed. If
this window closes, the timer stops running. So you can close the database window to
stop its timer.
▪ A window can only have one timer running. If you install a new timer in the same win-
dow, it replaces the one you last installed. So if you run the Install OnTimer Script
step with no script specified, then you effectively turn off the timer entirely. This way,
you can keep the window open but stop its timer.
TIP
Timers can be trouble (after all, if you accidentally schedule a complicated script to run every
second, it can keep your database so busy that it's tough to do anything else, including unschedule
it). While you're working out the kinks in your timer-based process, make a new window to work
in. Then if you accidentally get a timer running that won't stop on its own, just close the bad win-
dow.
Here are some situations where a timer might come in handy:
Search WWH ::




Custom Search