Database Reference
In-Depth Information
Script Triggers
You don't have to wait for someone to click a button to make a script run. Using script trig-
gers , you can tell FileMaker to automatically run a script whenever someone performs a par-
ticular action. You can apply a script trigger to a layout or an individual layout object. For in-
stance, you might run a script when someone first switches to a particular layout or trigger a
script when she tabs into a field.
You learn how to use script triggers and more about how they behave at the end of this
chapter.
UP TO SPEED: A SCRIPT ACTION OR A SCRIPT?
Attaching a single script action to a button is so easy that it's tempting to use that technique often.
But even if your buttons do only one thing, you'll still save time in the long run if you create a
single-line script, and attach that to your button instead. Yes, it's a little more work upfront, but
scripts have a lot more flexibility over the long haul. Here's why.
Lots of the initial development work in a database has to do with helping the users get around. So
many of the first buttons you create just go to a layout, or to a set of related records. But what if
your business rules change—like from now on, only managers can see a customer's payment his-
tory? You have to figure out how to stop unauthorized folks from seeing payment data. With an If
statement ( Logical Functions ) that checks Get(PrivilegeSetName) , a script can see who's logged
in to the file before it allows the Go to Layout script step to run. But you have to write the script
and then find all the 14 places you created a button with a plain-vanilla Go to Layout script action
and switch those buttons to Perform Script actions that run the new script. If you'd written a Go to
Layout script in the first place, and attached that to your 14 buttons, you could handle this new
wrinkle just by editing the script. No time wasted finding all those Go to Layout buttons, or worry-
ing about what happens if you missed one, because the script can work the same way from every
button.
Timer Scripts
Using the Install OnTimer Script script step, you can tell FileMaker to run a particular
script periodically. For example, you can give the user feedback during scripts by setting a
message that displays in a merge field on a layout. But you won't want to leave that message
hanging around forever, so use the Install OnTimer Script step to clear the message.
OnTimer scripts work by setting a timer that starts ticking in the window that's active when
the script is run. Then you set an “Interval seconds” option that tells FileMaker how often to
run the script. OnTimer scripts run repeatedly until you stop them. So they can be alarming to
work with until you get used to their ways. But OnTimer scripts run only in the window they
Search WWH ::




Custom Search