New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Using layout-based triggers

From: FileMaker Pro 11 Essential Training

Video: Using layout-based triggers

Another group of Script Triggers are called layout-based Script Triggers. These are the triggers that you can assign to any given layout that will run an event or a script on the load of a record, for example, or the commit of a record, for loading of a layout, entering a new mode, or exiting a mode. But unlike their counterpart, the object -based triggers, they're set up on the Layout Setup dialog. So instead of going into Layout mode and just assigning them to an object, like we do to object-based triggers, we still have to go into Layout mode. And if you go into Layout mode in our Exercise File, you will see that there is this little pencil icon.

Using layout-based triggers

Another group of Script Triggers are called layout-based Script Triggers. These are the triggers that you can assign to any given layout that will run an event or a script on the load of a record, for example, or the commit of a record, for loading of a layout, entering a new mode, or exiting a mode. But unlike their counterpart, the object -based triggers, they're set up on the Layout Setup dialog. So instead of going into Layout mode and just assigning them to an object, like we do to object-based triggers, we still have to go into Layout mode. And if you go into Layout mode in our Exercise File, you will see that there is this little pencil icon.

This will allow us to bring up the Layout Setup dialog. You can also get to it under Layouts > Layout Setup. You will notice that there's a tab all the way on the end here called Script Triggers. This reveals a list of all the different Script Triggers that are available for any given layout. Let me take a moment to briefly review the different triggers that are available. The first trigger is called OnRecordLoad. This triggerss a script to run after loading a record. Now, there are several actions that can load a record, including switching from record to record, switching layouts, because every time you go to a new layout you have to have a new active record, so that means that a record is loading, opening a new window also selects an active record.

creating or deleting a record, if you delete a record, it has to go to a new record. or performing a Find operation, because after you perform Find, you go back into Browse mode and one of the records becomes active. So this one is tricky. There are a lot of different areas that can actually load a record. You might consider using the OnRecordLoad if you have a table with records from different types that need to be displayed using different layouts. So, for example, if we had a different Customer Detail Layout designed depending on the status of a customer, then by simply navigating to another record, by saying go to next record in your Layout navigation, you could present a different layout to the user.

So you can have one for vendors, one for customers, one for employees, all happening when you're loading a new record. OnRecordCommit triggers a script to run before a record has been changed and is committed. So we have been talking a lot about committing a field, but what you might not be aware of is that you can make a change in a field, tab to another field in that same record, make another change, but you haven't yet committed either of those fields. Tabbing within a record will not commit any of those changes.

But then, if you make some changes in fields, tabbing through each field on the same record, and then you hit Commit, not only are you committing all the fields in that record, which by the way would trigger OnObjectSave triggers, but you're also committing the record. So switching to a different layout, if you've made some changes, that will commit your record. Pressing the Enter key or clicking outside of the record, that of course will commit it, because that commits fields. So any time you commit a field inside of a record, that commits the record. OnRecordRevert, this one's not too common.

It triggers a script to run before a set of records is reverted. Reverting only happens through the Revert Record menu. That's something where if you make a change, before you commit the change, you can go under the Records menu and hit Revert, and it will change your records back. It's really the only time that you would use the OnRecordRevert. OnLayoutKeystroke is similar to the OnObjectKeystroke. It's a very advanced trigger. It involves a lot of scripting and calculation and understanding to get it to work. It's a little outside the scope of this title, but if it sounds like something you might need, for example, it will trigger a script if you're on a layout and you hit any key or combination of keys on your keyboard, if that sounds like something you are interested in, by all means check the FileMaker Help.

Its got all sorts of details on the Layout Script Triggers. OnLayoutEnter simply triggers a script to run after a layout is loaded. So a layout is loaded most commonly after you switch or navigate to a layout. So that means we've loaded to this layout. So if you have a layout that has certain records on it that need to be sorted in a certain fashion, or if you want to perform a Find anytime you get on a certain layout, well, this is the type of thing that you would use there is the OnLayoutEnter. There is also a OnLayoutExit, which just does the inverse, which means right before you leave the layout, it would trigger the script to run.

Then there's the OnmodeEnter and OnmodeExit, and those are pretty much doing what you would imagine they would do. If you want to switch between Browse mode and Find mode or Find mode to Browse mode, that type of thing, you can run a script before you actually switch modes, And then OnmodeExit means if you're leaving Browse mode and going into Preview, it would trigger a script. Then of course once you get into Preview, it could trigger OnmodeEnter if you wanted it to. OnViewChange is when you switch views.

Views, of course are the Form View, List View, and Table View. So same kind of thing as the modes, but in this case it would be for any change from a view. So in our example that I am going to show you, we are going to attach a script to the loading of a layout, so that way anytime a user goes to this layout, the script will be run, and they'll see a group report onscreen. So if you remember from our chapter on Reporting, we've set up a subsummary report and of course the subsummary report needs one important thing to trigger it, and that is sorting by the break field.

So now we could remind our users and continue to train them to say every time you go to this report, you have to sort by the related company name field. Or we could simply add an OnLayoutEnter Script Trigger and choose our script that we created; we could choose an existing script, a script maybe we've created to run it, or we can just create a special script by hitting the Plus button, create a new one that's called Sort By Customer.

Then we can navigate down to Found Sets, double-click on Sort Records, and without bothering them with a dialog, we'll pop-up and say, Customers CompanyName, because as you see here, that's what our break field is, and that's how we set up this part. You can, for a refresher, go back into the Reports by Subsummary section and watch that movie again, but you will realize that the report will just look like a list in Browse mode unless the Sort happens.

So this way we say, Sort By Customer, OK, and we have a special script we just created just for this trigger. We hit OK again. We see it listed here. In this case, we are going to keep it on Browse mode. We are not going to sort in Find. That wouldn't make sense here. But we are going to do it Preview, in case somebody wants to Print Preview this from another layout; they'll at least see it grouped. So now we hit OK. Let's go into Browse mode, Save our changes. So you see, we are still on this layout. So we haven't left and loaded it again, but this is our subsummary report, but without sorting, it doesn't look like much.

In order to trigger this, we have to leave the layout. We will go to Customer Detail, and now we can navigate back to Invoice Lists. That's the layout that before we didn't see grouped. Now when we go to the layout, we see it grouped. As a matter fact, if we navigate all the way to the first record by typing in 1 and hitting Enter, we see everything grouped very nicely. So now no matter how we navigate to this layout, in either Browse, or as you see here Preview mode, it's automatically going to sort for the users.

As a matter of fact, we never even have to train the user to be able to sort these records. You can see that it might be just as handy to use Script Triggers on the layout level as they are on the object level. So it's probably a good idea for you to get familiar with these triggers before you start writing scripts, or even designing layouts, just so that you know the different actions that you can perform and how your scripts can be triggered on either the object or layout levels.

Show transcript

This video is part of

Image for FileMaker Pro 11 Essential Training
FileMaker Pro 11 Essential Training

94 video lessons · 14801 viewers

Cris Ippolite
Author

 
Expand all | Collapse all
  1. 7m 22s
    1. Welcome
      1m 8s
    2. Understanding the FileMaker family
      2m 15s
    3. Using the FileMaker Quick Start screen
      2m 52s
    4. Using the exercise files
      1m 7s
  2. 21m 9s
    1. What is a database?
      2m 26s
    2. Flat vs. relational databases
      2m 29s
    3. How FileMaker works
      4m 48s
    4. Understanding the essential preferences
      3m 13s
    5. Touring the interface
      8m 13s
  3. 11m 44s
    1. Creating databases from templates
      2m 29s
    2. Creating new databases in the spreadsheet-like format
      5m 35s
    3. Importing tables
      3m 40s
  4. 9m 9s
    1. Determining which tables you will need
      5m 10s
    2. Creating tables in the Managing Tables window
      3m 59s
  5. 34m 47s
    1. Understanding relationship types
      6m 58s
    2. Diagramming relationships (with ER diagrams)
      8m 50s
    3. Determining which key fields you need
      5m 18s
    4. Defining primary and foreign keys
      7m 56s
    5. Creating relationships using the relationships graph and table occurrences
      5m 45s
  6. 50m 34s
    1. Deciding what fields you will need
      5m 34s
    2. Understanding field types
      7m 54s
    3. Defining fields
      9m 56s
    4. Using Auto Enter options in fields
      9m 33s
    5. Reviewing field validation options
      8m 16s
    6. Building with container fields
      9m 21s
  7. 14m 8s
    1. Creating and duplicating records
      5m 40s
    2. Editing and locking records
      4m 42s
    3. Deleting records and backing up files
      3m 46s
  8. 21m 6s
    1. Importing data
      9m 57s
    2. Importing records to refresh data
      7m 2s
    3. Exporting data
      4m 7s
  9. 18m 30s
    1. Understanding layouts
      4m 15s
    2. Using the Layout Assistant to create List views
      7m 59s
    3. Using the Layout Assistant to create labels and envelopes
      6m 16s
  10. 27m 11s
    1. Using the Layout Setup dialog box
      4m 54s
    2. Understanding layout parts
      4m 40s
    3. Understanding the new Inspector
      2m 26s
    4. Exploring the Status Area in Layout mode
      6m 46s
    5. Managing layouts and layout folders
      8m 25s
  11. 41m 9s
    1. Arranging, aligning, grouping, and locking layout objects
      11m 5s
    2. Placing and formatting objects, parts, and graphics
      4m 10s
    3. Formatting fields and applying field attributes
      8m 26s
    4. Setting field behaviors
      4m 4s
    5. Using the Tab Control feature
      9m 8s
    6. Setting tab order
      4m 16s
  12. 36m 48s
    1. Using the basic find functions
      7m 31s
    2. Reviewing new requests in the Find mode
      5m 54s
    3. Establishing search operators
      6m 43s
    4. Constraining or extending found sets
      3m 24s
    5. Finding records using date, time, or timestamp criteria
      5m 18s
    6. Using Fast Match and Quick Find
      4m 41s
    7. Working with saved finds
      3m 17s
  13. 17m 28s
    1. Sorting with one criterion
      6m 4s
    2. Sorting with related fields
      2m 18s
    3. Sorting with multiple criteria
      1m 36s
    4. Sorting using custom values
      3m 14s
    5. Sorting using buttons
      4m 16s
  14. 17m 14s
    1. Reviewing Field/Control styles
      5m 43s
    2. Creating and applying static value lists
      5m 20s
    3. Creating and applying dynamic value lists
      6m 11s
  15. 23m 52s
    1. Previewing pages and print options
      6m 20s
    2. Printing in different views
      2m 54s
    3. Sliding objects
      3m 26s
    4. Printing merge letters
      4m 53s
    5. Saving as a PDF or Excel file
      6m 19s
  16. 15m 1s
    1. Building simple reports with summary fields
      4m 36s
    2. Creating subsummary reports
      6m 51s
    3. Creating subsummary reports in Table view
      3m 34s
  17. 52m 19s
    1. Defining calculations
      2m 31s
    2. Exploring the Calculation dialog box
      5m 8s
    3. Using number functions
      12m 41s
    4. Using date and time functions
      4m 58s
    5. Using text functions
      11m 43s
    6. Using get functions
      4m 0s
    7. Using logic functions
      11m 18s
  18. 46m 56s
    1. Understanding scripts and script steps
      2m 23s
    2. Assigning script steps to buttons
      3m 54s
    3. Understanding the ScriptMaker dialog box
      8m 28s
    4. Creating multi-line scripts
      6m 44s
    5. Adding find criteria to a script
      4m 58s
    6. Understanding the If script step
      8m 36s
    7. Using script parameters
      4m 42s
    8. Reviewing the Send Mail option
      7m 11s
  19. 28m 0s
    1. Understanding script triggers
      2m 41s
    2. Using object-based triggers
      11m 58s
    3. Using layout-based triggers
      7m 51s
    4. Using file-based triggers (Open and Close scripts)
      5m 30s
  20. 56m 42s
    1. Using related fields
      7m 18s
    2. Creating portals and using portal filtering
      10m 38s
    3. Using related fields in calculations
      7m 6s
    4. Understanding multi-predicate relationships
      11m 11s
    5. Using the Go to Related Record script step
      7m 26s
    6. Creating a chart
      13m 3s
  21. 30s
    1. Goodbye
      30s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.