Q: I recently inherited the responsibility for a shared FileMaker Pro 8 database used by six others in my company's customer service department. My co-workers are hinting that they'd like to have a little more "polish" put on our system, specifically in automating our reporting process. I suspect the answer lies in better scripting, but there are so many script functions and I'm not sure where to start. I'm comfortable editing layouts, defining buttons, and writing simple scripts. Can you provide any pointers, please, to make generating reports a little slicker?
A: Your intuition is right on the money. Scripting in FileMaker Pro lets you automate workflow, interact with the user, and create responses based on that input and other conditions, such as current date, number of records found, or identity of the logged in user. For a detailed look at scripting in action, see Paul Mitchell's article, "Automate Navigation with FileMaker Pro Open Scripts." You've already done some scripting, so you know the basic premise is quite straightforward: open ScriptMaker from the Scripts menu, create a script, and add a series of script steps that achieves the desired outcome. Ah, but which steps to use, and how to best apply them? With more than 130 script steps to choose from, there's the rub, as Shakespeare's Hamlet would say. Additionally, many script steps can directly access the specify calculation dialog -- providing a powerful synergy that creates infinite options to craft the outcome you seek. I'll suggest a few script steps that are popular hard workers, and demonstrate how they can work well together.
One way you might automate and polish your co-worker's reporting workflow is to intelligently guess the dates for the report. Let's say every week each of your co-workers runs a month-to-date report of customer service requests they've received, summarized by category. To select the records for their report, they currently must do a manual find on two fields: RecordCreatedDate, the date the customer service request was created, and RecordCreatedBy, containing the FileMaker Pro file login (account name) of the employee who took the request. Then they click a button on your report menu that prints the report. You want to revise that behavior to automate the find, but also let the user customize the date range before running the report. Also, you don't want running the report to disturb the current found set of records. For a little added functionality, you'll even let the user customize the report title that prints at the top of the report.
To get a clear idea of the process you'll need to create, it's useful before opening ScriptMaker to write out the sequence of steps in general terms -- sometimes called pseudocode. A script for the proposed scenario might proceed as follows:
User starts script from a button or the Scripts menu.
1. Present a Custom Dialog with OK and Cancel buttons, and three pre-filled entry fields:
- Start Date (first day of the current month, or last month if today is the 1st)
- End Date (yesterday's date)
- Report Name ("MTD Customer Service Summary")
2. If user clicks on Cancel, end the script. If user clicks on OK, Open a New Window (so user's current window remains undisturbed).
3. Go the layout for the desired report.
4. Find current user's records within date range from the Custom Dialog.
5. Sort as needed.
6. Preview the report.
To accomplish this workflow, the script steps you'll want to use, among others, are:
Show Custom Dialog
If / End If
Enter Find Mode
Set Field
Perform Find
You'll also need three global fields -- two of field type Date and the third as type Text -- to hold the search start and end dates and custom report name entered via the Custom Dialog. Regular fields would work, but the advantage of global fields is that you can temporarily store data without concern about which record you're on or move to.
TIP
If you haven't used a global field before, just think of it as a regular FileMaker Pro field (text, number, date, time, timestamp, or container) whose content is shared by all records. If the value of a global field changes in one record, that value is immediately available to all other records. In fact, the content of a global field is available to any record in any table in your file -- even unrelated tables -- and it can also be shared across files if at least one relationship exists between them. You can make a field global when you're defining fields in the Define Database dialog (Manage Database in FileMaker Pro 9). Select the field name and click on its Options... button. Select the "Use global storage" checkbox under the Storage tab to make this a global field.