Scripts are all about saving you (and your users) time. And what could be less time consuming than something you don't have to do at all? As you learned earlier in this chapter, script triggers let you tell FileMaker to run a script automatically in response to something that already happens when people use your database. You'll get a brief introduction to each of FileMaker's trigger options here. Then, throughout the next chapters, you'll use these triggers in key places to make your database come alive.
Script triggers come in two flavors. Layout triggers apply to the layout as a whole. These triggers include actions like loading or committing a record, switching layouts, or pressing a key on the keyboard. 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.
In addition to the action that fires a script trigger, timing also comes into play. Some triggers fire before their controlling action, and some fire afterwards. As with scripting itself, the order in which a step or a whole script occurs can make or break a script.
So take care when you start to apply triggers. They're simple to apply, but can be tricky to predict unless you understand all their behaviors. So 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.
Since you'd only view the Invoices with Balance Due layout when you want to find unpaid invoices, it makes perfect sense to run the Find Unpaid Invoices script every time you switch to that...