In our last post, we discussed grabbing data from a database using AppleScript. Although several excellent databases exist, we’re going to use FileMaker Pro because many Mac lawyers use FileMaker as a case management tool. FileMaker is an Apple subsidiary that creates several versions of FileMaker Pro, a database application. A database stores and organizes your data to help you manage that data. FileMaker Pro differs from most databases because FileMaker Pro includes tools to create a graphical user interface “on top of” the underlying database. Click here for an introduction to databases and FileMaker Pro.
Before we begin scripting FileMaker, we need to create a new database or use an existing database. Fortunately, FileMaker ships with several existing templates including a database to manage contacts. Because we’ll be using the data from FileMaker Pro to write a letter to a contact, we’ll use this existing database as our database.
Open the Contact Management database in FileMaker and enter a new record. (You may have to open and save the database first). For this example, we need only enter the first name and last name of a contact. In my example, I entered “Larry” for the first name and “Staton” for the last name. We’re done with FileMaker for now, so we can hide it. (We’ll be back to FileMaker later, so don’t quit it yet.)
When we want to script an application, I find it helpful to review the application’s dictionary in Script Editor, so let’s do that now. Open up Script Editor and select “Open Dictionary” from the File menu. Select FileMaker Pro from the dialog box. You should now see FileMaker’s scripting dictionary:
Let’s focus on what makes a FileMaker database. FileMaker has a strange dictionary. The main elements fall under the “Subset of the Core, Table, and Database suites” category. Select this category and scroll down to the database container. From the dictionary, we can see that database is the top-level container. Each database is made of tables. Tables organize related information in the database. Each table is made of records. A record is a single entry in the database. When we entered a new contact into the database, we entered a new record—a single entry into the database. Tables also contain fields. Each field stores a single piece of information. We want to access these individual pieces of information. In our example, we want to get the value of the first name field and the value of the last name field of our contacts database. After we get this information, we can push it to any other application, such as Microsoft Word or iCal or Mail. So let’s write a script to get these values.
Open up Script Editor and type the following:
tell application "FileMaker Pro" tell database "Contact Management" tell table 1 tell record 1 set firstName to field "First Name" set lastName to field "Last Name" end tell end tell end tell end tell set fullName to firstName & " " & lastName
Now “Run” the script. In the “Result” window at the bottom of the Script Editor window, you should see the name that you entered into FileMaker:
Study this script and let it sink in. In my next post, we’ll break down the script in some detail.


Brock Dagenais on May 22nd, 2008 at 0:14 says:
Okay thanks, it’s sunk in. But what happens next!?