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.
Creating Scripts in FileMaker is an essential part of developing a FileMaker database, and making Scripts as intelligent as possible will take much of the guesswork out of using your database. A great way to add intelligence to your Scripts is by adding conditions to the Scripts. That way they are given instructions on what to do in certain cases, and that way you can have a Script that actually have many different results, depending on these conditions that you set up. If you recall in the Calculations chapter, we discussed a group of functions that we're calling the Logical Functions, that allow you to perform a test or ask a question, let's say, and then you provide multiple different results depending on whether or not the question was true or false. Or if you have multiple questions, you provide different results depending on what part was true.
You can do the same thing in a Script using a set of Script Steps based on the If Script Step. So the If Script allows you to ask a question during a Script and then perform different actions based on whether or not the conditions were met. Let's take a look at these set of Scripts by opening up our exercise file and then opening up Scripts > Manage Scripts, and we'll see our Print Welcome Letter Script that we had created previously, and now we're going to hit the Duplicate button, and we see a new Print Welcome Letter Copy has been created. Let's double-click on that to open it up, and we see all the steps that we had in here previously.
All we're going to do is we're going to modify this Script. We're going to modify this a little bit because here we were doing the Find on behalf of the user. Instead what we're going to do is we're going to take the user into Find mode and allow them to create the Find criteria. Then we're going to perform the rest of the steps against their remaining Found Set. But in our Script, when they actually hit the Print button, it's going to check to see what the status of the user is, and depending on what their status is, it's going to take them to one layout, which would be the Welcome Letter layout. And if the Status is Inactive, for example, it's going to take them to a new layout that we've got called the Welcome Letter Inactive version, which both say different things.
So this way they can go through one record at a time, and every time they hit the Print button, it's going to automatically take them to the correct letter, so that it can be printed. So first we're going to clean up a couple of things; we'll get rid of the Perform Find, and we will keep all the rest of them for right now. But what we're going to do is, instead of navigating them to the layout, we're going to say If. Double-clicking on If will actually add two Script Steps. You see we've got the first Script Step If and then the second Script Step End If. The If starts the test and the End If ends the test, because if you remember in our Calculations, we had an area that was inside parentheses that determined what our test was going to be.
So this way this Script knows when we're done testing, and then it can perform the condition based on the result. So If will always be at the beginning and just like bookends, the End If will be at the end of our test. So we'll want to place the If step where we want to add the condition, so in this case, it's going to start at the very beginning of our Script. And then End If will be after the Go To Layout. Now, this means that every step that falls in between If and End If will only perform based on a condition. Now in order to create that condition, we have to double-click on the If Script Step, or we can hit the Specify button; in either case it takes us to the Specify Calculation dialog.
Now this Specify Calculation dialog is a little bit different than the one that we've been using recently because you see there are no results on the bottom. In this case, you see the Calculation result must be Boolean, not a field type or a file type; it just has to either be true or false or yes or no. So we have to take that into account when we're writing our test, for example. So if you remember, our goal here is to find out what the Status of the Customer is, and then based on the Status we're going to send them to a certain Layout to print. So let's say, first if Status or Customers Status equals, then we'll put in Inactive, and then we'll hit OK.
So now we're saying the test is If the Customers Status equals Inactive, then we want to do something, and then of course we're done with the test. Well, right now we're telling it to do something, and that do something is Go to the Welcome Letter layout. But if you recall, we've got a new layout that's called Customer Inactive Letter. So now we know that if it's Inactive it has to go to the Inactive Letter, but what about if it's not Inactive? Well, that's where these other items come into play. If you remember in the If Step inside Calculations, you can say If, and then you have a test, and then you have result number one or result number two, so basically you're saying If this test is true then do this; otherwise, do something else, and Else acts as the otherwise.
So here, I can say If the Customers Status is Inactive, go to this layout, otherwise we're going to have it go to another layout, which you might not realize is you can select an existing Step and hit Duplicate, then use the handles to move it down to the appropriate location, and now we can have this print our regular Welcome Letter. So now our Script says, If the Customers Status equals Inactive, then go print the Inactive Letter; otherwise, print the regular Welcome Letter. And now you see also we can go down here to our Custom Dialog window, and we can make it a little bit more specific, for example. You see here how it says, "Your Letter Has Been Printed".
I want to introduce you to another concept that's called setting a Variable. If you double-click on this Set a Variable, this is something that's similar to when you're using a Calculator. You do 2+2=4, and then you save that 4 to memory. So this allows you to save something to, let's say, like a Clipboard. You're familiar with doing Copy and Paste. Well imagine if you had a Clipboard that when you save something to the Clipboard you could save it and name it, so that you could save multiple things to the Clipboard that don't overwrite each other, unless of course they had the same name.
In FileMaker that's the same concept that we use here for a variable. In this case, I'm going to double-click on the variable, and we need to name it something. And inside FileMaker, you have to precede the name of a variable with a dollar sign, and then I'm going to put the word Status, and now we have to save a value to this field. So when it's on a record, it's going to save the Status here to Customer and we hit OK. So now what this means is that after it determines that some thing is Inactive, it's going to go to a certain layout and set a variable, or save a little piece in the memory of FileMaker, and name that dollar sign Status and to that little piece of memory in FileMaker it's going to put the term Inactive, in this case.
Otherwise, and we'll hit Duplicate, if it's not Inactive, it'll go to a different layout and save a different value. Now the reason that we're doing that is because, in our Custom dialog, you see we can specify Your, and now I'm going to create some text, space, quote, ampersand, and now I'm going to reference that variable. Variables are a little bit of an intermediate or advanced concept, but I wanted to at least briefly introduce you to them here because they are a pretty important part of scripting, as you get more familiar with scripting.
Again, it's just a little way to set something to a memory then pull that back from memory later, and here you see we're referencing it later on in our Script. So let's take a look at how this Script is going to work. We'll hit Save, we hit OK and we go into Layout mode and we select the button, Format > Button Setup, and it already says Perform Script, but let's pick a new one, the Welcome Letter Copy, and let's hit OK. Now let's take a look at how this works in Browse mode.
First, let's do a Find, Find, and let's say Find everybody in the State of Texas. It gives us three records, first record, Status of Pending, so they're not Inactive. This one is Inactive, and the last one is Pending. So let's see what happens when we run our Script on this record. You see what it does is it creates the Welcome Letter, but in this case it's printing more than one record. To remember how we can affect that, we can go into our Script, Print Welcome Letter Copy, hit Edit - by the way we can name this Inactive - and down in the Print, we can say Current record. Remember that allowed us to toggle between those and the two different Scripts.
So now let's try. We go to the first record. Sure enough, we get one record, and you see it's the Welcome Letter, and you also see that our Status shows up in the pop-up window. Now let's try going to another record, same Script, but this one is Inactive. Now we hit OK, and we see it's printed in Inactive Letter, and it's called at the Inactive Letter. So it's the same Script, but in this case we've added a condition using the If Script Step or the family of Script Steps, and we've also passed through using something that's called a Variable inside of the Script, which allows the same Script to have two different results based on a condition that we've developed inside of the database.
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.