Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
In FileMaker Pro 11 Essential Training, Cris Ippolite demonstrates the principal features and functions of this popular database software, including creating tables and relationships, managing fields and records, and working with layouts. The course shows FileMaker developers how to find, sort, and share data as well as how to create reports, calculations, and scripts. It also covers brand new features in FileMaker Pro 11 such as the Inspector tool, charting, and portal filtering. Exercise files accompany the course.
The last set of Script Triggers that we'll be looking at aren't part of the new Script Triggers that were added in FileMaker 10, but instead, these Script Triggers have existed in FileMaker for many, many versions. So this is something that you might even be familiar with if you've worked with older versions before. If not, let me introduce them to you. The two Script Triggers that we are talking about for file level can both be applied to a file, under the File > File Options menu. There are these two that you see here. So one can trigger when you open a file, one can trigger when you close the file.
And they have some specific names. The naming is important here; it helps you understand how these things work. So as its name implies, the OnFirstWindowOpen Script Trigger will activate upon opening the first window for a file. Now, this is important. These concepts might be a little bit beyond essential, but a file can be opened without a window being opened. That can happen if your file is a child file and somebody opens the parent; FileMaker has to open up the child file hidden, and therefore no windows open.
So if you have an OnFirstWindowOpen Script Trigger attached, it won't fire until the user actually goes in and navigates to the file or tries to open the file themselves. So it's not just on file open, as you might think because of the way that you're performing the script when opening a file, but just keep in mind that opening it can happen in a couple of different ways. But this is really just when an user interacts with it and tries to open the file, whether it's a local file or whether it's hosted on a server. So when it's hosted on a server, it's going to fire each time a new user logs in and initiates their own session.
So that's why they call it OnFirstWindowOpen rather than OnFileOpen. The other one, conversely, is called OnLastWindowClose. So you could have multiple windows open in your file, and it's after the last one of those windows closes. That's how your file has officially closed. So this is a script that would run then. But it runs before the last window is closed, because otherwise if the last window is closed, the file is not even active anymore. So the setup for both of these is found under File Options. The OnFirstWindowOpen can be set here. I can choose Specify and choose any one of the scripts in your database.
But notice there's no script parameters for either of these two. The other Script Triggers do have the ability to enter a script parameter. So let's test this out. I've already created a script in this file that, when executed, locates all of the records that were created by the user who is logged in. So in other words, it's finding your records whenever you log in. I thought that might be helpful. As a matter of fact, if I close this window for a second, you can see down here, Record Created By. We've got a series of records, and most of them are created by someone else.
But I do have some records in here, for example, if you click in and do Command+I or Ctrl+I on Windows, that will invoke the Field Index. You can see that there is records either created by Admin or by someone else. Now, I am logging in as Admin. By the way, throughout this entire title we've been logging in as Admin, because if you look under File Options, as long as we are in there, you notice that above the Script Trigger, you see that it says, when opening this file Log in using, and then it gives an Account Name and Password.
Now, if you're interested in information on Account Names and Passwords, you can check the FileMaker Help, or if you're an Online Training Member or Subscriber, feel free to go look at previous versions of FileMaker Beyond the Basics for information on how to set up accounts and privileges. But your FileMaker Help gives you a plethora of information there. But all you need to know here is that because this is set, every time we open one of these Exercise Files, we are automatically being logged in as Admin. So that's who I am when I log into the file - not someone else.
So let's go back under File Options. Actually, while we are in there, we are going to say Perform script, and then we are going to scroll down to find a script, and we are going to choose Open Script. If we take a look at the script using Edit, you can see that what it does is it grabs the person who has just logged in, goes to a certain Layout, performs a Find that puts that same variable in the search criteria. Again, this is a little bit more of an intermediate script, but I've got this one in here and inside your Exercise Files. You can copy it off the screen here and try it out on your own solution if you would like to.
But let's apply the Open Script to the OnFirstWindowOpen, and let's hit OK. So now you see we have got 1,523 records. I am going to close the file, and I am going to open it back up again. Now, you notice on open, I've got a Found Set of 25 records already. You see as I cycle through each one of those, they are all the records that I created, or the Admin created. So although you already may be familiar with these file-based triggers, if you've ever worked with FileMaker in older versions, if you're not though, they can be very useful, and they work just like layout or object triggers, but will run each time a file opens or closes, or more specifically when the first window opens or the last window closes.
These can help you set up a file the way you want to, regardless of the state of the file after the last user opened it. So no matter what somebody does in the file, you can reset it and go to different layouts and do all sorts of stuff, automatically doing things to the file based on the user if you would like to. All these things can be done with these two file-based Script Triggers, so it's certainly something that you want to get into your Script Trigger tool belt.
Find answers to the most frequently asked questions about FileMaker Pro 11 Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.