From the Field: Database Publishing with QuarkXPress and
InDesign - File Maker

Possibly the most common use of FileMaker in an AppleScript automation solution is as a repository for data to be flowed to documents in desktop publishing applications such as QuarkXPress and InDesign. Look again at Database Publishing Example.fp5. Each record in this database contains information about a particular U.S. president, some real, some imagined. This is a very simple database with fields for the president’s first and last names, photo, and whether they are real presidents or not.

Publishing Data from the Current Record In A FileMaker Pro Database
The task that you’ll first use AppleScript to automate is the publishing of information from a single record in this database to a desktop publishing template.

The template document that you’ll use contains a single picture and text box.

For whichever record the user happens to be browsing in Database Publishing Example.fp5 (this will always be the current record), you’ll want your script to gather and place the president’s full name in template’s text box and the president’s photo in the picture box.

In this solution you’ll be working with two applications, first with FileMaker Pro and secondly with your desktop publishing application. As your script starts with FileMaker Pro, reference it in a tell block, e.g.:

As you’ll be working with the database, Database Publishing Example.fp5, which is an element of the application FileMaker Pro, you’ll reference it in a nested tell block, e.g.:

If you’re catching the general drift here, you see that you’re building a reference, step by step, from the largest to the smallest container object. Therefore, the next step down the hierarchy is:

The names of the cell objects that you need to gather data from are: First Name, Last Name, and Photo. You’ll gather the data contained in these cells into three separate variables. In the AppleScript statement that follows, please note that firstName, lastName, and Photo are the names you will choose to give your variables. However, any other valid variable names would do:

You’ll go ahead and concatenate (join) the data contained in the firstName and lastName variables into a single variable you’ll call fullName. You’ll use a text constant to add a space between the president’s first and last name.

Now that you’ve collected the data your page layout application requires, you’re done working with FileMaker Pro.

Publishing Data from Multiple Records in a FileMaker Pro Database
A more powerful use of FileMaker Pro in AppleScript driven publishing automation solutions is to flow data from multiple records to multiple text and picture boxes in a desktop publishing template. Say you want to publish data for every “For Real President?” in Database Publishing Example.fp5 to the desktop publishing template.

The first thing your script will need to do is create a found set of records whose cell “For Real President?” is marked as “Yes.” In Database Publishing Example.fp5 the first two records have “For Real President?” set to “Yes.” As discussed in the FileMaker Pro Commands section in this, found sets of records can be created using the show command, as in:

Executing this statement creates a found set of two records in Database Publishing Example.fp5, i.e., it creates a document object. Remember that the database object refers to all records no matter the found set, and the document object refers to just the found set of records. Now that you’ve isolated the set of records you’re interested in working with, you’ll create another tell block to work with it.

If you want a script to do anything more than once, you’ll need a repeat loop. The solution requires that you publish data from however many records there are in the found set (document object) to a matching number of text and picture boxes in the desktop publishing template. The first thing you’ll need to find out is how many records are in the found set. A quick perusal of FileMaker Pro’s dictionary will reveal what you seek the count command. In the statement that follows, you’re putting the result of the count of records into a variable.

Now that you know how many times you need your loop to repeat, you’ll use the recordCount variable in a repeat loop that will allow your script to reference each record in the found set one at a time. In the statement below, the counter variable i is counting from 1 to the count of records contained in the record Count variable that, in your case, is 2. Therefore, the loop will repeat twice; its first iteration will reference record 1, its second iteration, record 2.

The next step will be to collect the required cell data into variables.

Lastly, you’ll pass the data you’ve collected to a subroutine called publish(), where your desktop publishing application takes over. In the subroutine call publish(i, fullName, thePhoto) you’re passing your counter variable i, the president’s full name fullName, and the file reference to the picture the Photo. The AppleScript keywords “of me” are required because the subroutine call is nested inside the tell application “FileMaker Pro” block. In other words, the command publish() is being sent to FileMaker Pro, which doesn’t have this command in its dictionary. The AppleScript keywords “of me” tell FileMaker Pro to send the command to the script itself where the subroutine is found.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

File Maker Topics