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

Using object-based triggers

From: FileMaker Pro 11 Essential Training

Video: Using object-based triggers

The first set of script triggers that we are going to take a look at are called object based triggers. These are triggers the deal mainly with the layout objects and most specifically, fields, although there are other objects that can affect these triggers. But most of the time, you are going to be dealing with the fields. For example, if you were to click into a field, or click out of a field or modify or save a field value, then that would execute a script and using a script trigger on a field or layout object is a lot more subtle of a trigger than having to rely on a user to press a button, for example, because of course, then you have to train them to do these things and say any time you do this, make sure you hit this button before you leave the layout, and do all that kind of stuff.

Using object-based triggers

The first set of script triggers that we are going to take a look at are called object based triggers. These are triggers the deal mainly with the layout objects and most specifically, fields, although there are other objects that can affect these triggers. But most of the time, you are going to be dealing with the fields. For example, if you were to click into a field, or click out of a field or modify or save a field value, then that would execute a script and using a script trigger on a field or layout object is a lot more subtle of a trigger than having to rely on a user to press a button, for example, because of course, then you have to train them to do these things and say any time you do this, make sure you hit this button before you leave the layout, and do all that kind of stuff.

So with these triggers, they act more behind the scenes, so quite frankly, you can run activities that the user is not even aware of. Then you don't have to train them to run the scripts. So this is something that's great that users can do something many, many times without them even knowing it's happening and not worry about them remembering to do things. All the triggers will be added to your objects while you're in Layout mode. So let's go in a Layout mode, into our Exercise File, under View > Layout mode, and we are going to want to choose an object, in this case a field.

So let's go to the Notes field, and we're going to select the entire Notes field, and once you have a field selected, you can go under Format to Set Script Triggers which is all the way on the bottom, and also you could right-click or Ctrl+Click to also get to these Set Script Triggers window. In either case, you'll see this dialog appear, and it gives you a list of all of the different Script Triggers that are available to you, to be able to assign to an object. So let me briefly describe each one of these triggers, and what they would do if you chose it.

So, the first one, OnObjectEnter; this triggers the script to run when the object becomes active. So, for example, there are several actions that could activate an object, such as tabbing or clicking to an object, like a field, or even tabbing into a Tab control, for example. The OnObjectEnter event can also be triggered by a Script Step that enters a field. So if you have a script that says Go To Field, then entering that field will cause another script to run. So sometimes you got to be a little bit careful with the combination of these things, especially if you are adding Script Triggers to an already existing database.

Tabbing to a button or a tab, not field, but just buttons or tabs, will activate the trigger, but clicking in a button or tab does not; however, clicking in a field will. Next you have OnObjectKeystroke, and this triggers a script when an object is active and a keystroke is received, meaning anytime somebody hits the F key, run a script. This is a little bit more of a advanced trigger,s since it involves a lot of scripting and calculation and understanding to get it to work, so consult FileMaker Help for details. And it's a little outside the scope of this title, but it might be of interest to you, if it sounds like that's something you could either with.

It's called OnObjectKeystroke. OnObjectModify triggers a script to run when the value of an object changes. So the value inside of a field, for example. Actions that triggers this event include things like typing in a field, selecting a check box, cutting and pasting into a field, or script steps like Insert Text. Additionally, switching tabs on a tab control will trigger this action, which is kind of interesting. OnObjectSave triggers a script to run after the object's data has been validated and saved but before the field is exited.

So Modify will a trigger script when something is changed, but OnObjectSave won't trigger this script until you click outside the field, validation passes if there is any, and then the field is committed; then it runs. OnObjectExit triggers a script to run before the active object is exited. So if you try to tab off of the field that will trigger a script, for example. Actions that trigger this would be tabbing on to the field, or just clicking on a different object, so you are changing the focus. Unlike OnObjectSave, this trigger will activate regardless of whether or not an object's data has been changed.

So exiting doesn't matter whether or not you have changed something and therefore save. So you got slight nuances to all of these things. But in FileMaker Pro 11, there is a new one called, OnObjectValidate. This triggers a script to run before the field level validation occurs. So, a validation actually occurs somewhere in between when you would make a change, and when you commit the record. So it happens before the record is saved to the database. So this trigger will launch in between those things, and it will do so before the validation so that you get a change to change the data in the field yourself if you would like to.

You could have a script that grabs two digit years and turns them into four digit years before the value even gets saved in the database. As a matter of fact, if you watch the video on the lynda.com Online Training Library called FileMaker 11 New Features, you will see an example of that very technique that I just mentioned. In this example, what we want to do is just simply check the spelling of a field once the user makes a change to value that was in the field and then they leave. So, in that case, we would say something like OnObjectSave, because of course, that's only going to run if something has been changed, and if the user tries to save it.

So let's go in here, and see if we have got any scripts that would fit this. Well we don't. So when the Specify Script Window appears, we can still create a script for this trigger, and we can do so by hitting this little Plus button there. And what we are going to do is name it Spelling and then scroll all the way to the bottom, and we are going to find a Script Step for Check Spelling. And here we go. We have got one for Check Selection under the Spelling section. So let's double-click on that, and it will select the entire contents, and we tell if what field we wanted to check, and we will pick Notes.

So now you see we have an OK button on our script because we are creating this through the Specify Script dialog. So now it's saved for us for automatically because we hit OK. If we hit OK again, we now see that this script is assigned to that object. There is one more decision you have to make before you leave here, though. You don't want to overlook it. You need to decide which mode you want this to work in. So by default, all the triggers for objects will run in Browse mode, and you have the option to also run it in Find mode. Now, this one wouldn't make sense, because if you were in Find mode and you were trying to search for a value inside Notes field, maybe you don't want the spelling to be checked because the user doesn't want their criteria changed.

So we will just leave at Browse mode here. Let's go into Browse mode and see how this works. Now, we have got a piece of data, we have changed the original value, and I am going to click outside the field, And you see that it makes the Check Spelling dialog pop up. So back in Layout mode, you will notice that in the bottom right-hand corner, there is a layout badge for including in Quick Find, which is the green magnifying glass, but now also you see that there is a little script icon with sort of a paint ball splat next to it.

That indicates that this field has a Script Trigger assigned to it. So you will notice that if I go in here, right-click or Ctrl+Click, and remove the Script Trigger, that that badge disappears. Let's look at another example in this same file. So let's say in this case we are having trouble losing our original contact information. So, for example, people are coming in, and they are changing the first and last name of the contact, but we are losing who the old contact was, in case we want to follow up with somebody or in case we are trying to remember who a person was, and where they used to work even after they are gone.

Well the problem with that is is after you change your name, it's automatically deleted from the database because it gets committed to the database. So let's say we have got some scripts that we have created, under Manage Scripts, and one of them is grab the existing full name. And if you remember in a previous movie, we talked about the concept of a variable, which is like having your own mini clipboard, and inside that clipboard, you are going to save a certain value. And the value we are saving in this case was the original full name of the person, and we are going to set it to a place in memory.

That's just one script with one step. Then we have another Script Step here called Create Log. This one is a little bit more complicated. Feel free to check this out when you have a little bit more time, but it uses a lot of these variables, but essentially what it's doing here is committing the record, then setting a variable with the new name that was just made. So if you change it from John Smith to Bill Jones, it's going to save the Bill Jones. And then it's going to the object, which is a Script Step that allows us to navigate to a object that has been named in Layout mode, and in this case, it's a Notes tab, and it's going to set a value in the Notes field that includes the value that's currently in the Notes field along with the old value and the new value and then go back to where you started.

Now, this script is intended just to demonstrate the OnObject trigger. This is certainly a more intermediate or advanced scripts, but I urge you if you are interested or curious to take a look at this, feel free to open up the Exercise Files and poke around in the script and see how it all works. What, we are going to do in this case is we are going to go into Layout mode and you understand that the two scripts that we have got - well I am going to go here, and I am going to pick the ContactFirstName, and I am going to right-click or Ctrl+Click on Mac, and I am going to choose Set Script Trigger.

Now, in this case I have to figure what's going to trigger the script? Well the whole idea here is that if somebody saves a new name, so really it doesn't have to deal with if they click into the field, then if they modify, we really don't want to do it right when the modification happens, we want to do it after they have done all the changes and then hit Save. The problem with Modify is it will trigger the second you hit any keystroke. So, how about OnObjectSave? Any time they are trying to save a new change, we are going to say, CreateLog, and what you might not be aware of is that you can assign multiple script triggers with different scripts to the same object.

So in this case, sure, that's great that we are creating a log when we hit Save, but how about when we Enter the object. We are going to grab the existing full name. So, now what we are doing is when a user clicks into this field, and makes a change, it's going to grab the name that was in there before they make a change. And then after they make a change, it's going to grab the new name, and it's going to go into the Notes field and paste all that information in there for us. So, let's take a look at how this works. You will notice the layout badges. Go into Browse mode. Save our changes.

Let's go and change the name. So here I have entered the field I am modifying. I haven't saved it yet, as you notice if you look over Notes, now that I have switched over to Notes, what I have done is I have committed my change. So I didn't have the change committed by clicking outside the field, but switching over to another tab committed it. So, now you see before where we had sample notes. Now it says the previous contact name was, and then it gives the timestamp of when that happened.

So, for example, I could change it again. This time I will click outside the field. Now you see another line has been added. The previous contact was Cris Ippolite, and so on. So, in this case, this is something where a user might not even know what's going on, but they can make all the changes that they like, and all the while a log will be recorded. So if you are interested in the script, I know it's a little bit beyond essential training, but feel free to take a look at it, or even copy and paste it to your solution and see if you can get it to work to add a little bit of logging functionality. So, as you can see, object-based triggers are extremely useful. They can be used one at a time, assigned to fields, or layout objects, or even several different triggers can be assigned to the same object.

So, now let's move on and take a look at some layout-based triggers in the next movie.

Show transcript

This video is part of

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

94 video lessons · 14866 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
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed FileMaker Pro 11 Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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.