Help

Table Of Contents
Creating scripts to automate tasks
F
ILEMAKER PRO HELP 419
Creating scripts to automate tasks
Scripts can do simple tasks like setting print orientation or complex tasks like preparing a
customized mailing to each client.
For example, you could define a complex set of tasks that creates a thank you letter to clients in
your Clients database who have made purchases in the last week. The script composes a letter
tailored to each client. The script switches to Preview mode and pauses so you can see what the
letter looks like before it prints. The whole task is initiated by clicking a button on the Sales Entry
layout.
You build scripts by selecting from a list of FileMaker Pro commands, called script steps, specifying
options (if necessary), and arranging the steps in the correct order to perform the task.
Note Many FileMaker Pro scripts can be made available to web users when you publish your
database using FileMaker
WebDirect. See the FILEMAKER WEBDIRECT GUIDE.
Related topics
Script steps reference (alphabetical list)
Script steps reference (category list)
Planning a script
The more time you spend planning your script, the more likely that it will accomplish what you want.
As you plan, ask yourself these questions:
Can you separate the task into smaller tasks? You can define sub-scripts for each small
task, and then define a script that performs the sub-scripts. It's easier to design and test
several small scripts than one complex one. You can also reuse sub-scripts in other areas.
(Use
Perform Script script step to perform a sub-script inside another script.)
What script steps should be executed under what conditions? Should every script step
always be executed? Should some be executed a number of times until a certain condition
is met? Should the script call other scripts and sub-scripts? You can control the progression
of the script in a number of different ways. See
Control script steps for more information on
creating scripts with conditional steps.
Do you want the script to run in a particular layout? Because scripts are defined at the file
level and can be called from any layout, you should make sure the script will operate in the
layout or layouts you expect. Use the
Go to Layout script step to change layouts.
Should the script work on all records in the database, the current found set, or a specific set
of records? (Use the
Found Sets script steps to include only the records that you want to
work with in the found set.)
Is all the data you need in one database file, or will the script operate on more than one file?
If you're using multiple files, which ones should the script open? In which file should the
script(s) be defined? In most cases a script should be defined in the same file as the data it
is processing. Database solutions with more than one file may need separate scripts in each
file, depending on the complexity of the task you are trying to script.
With which record should the script start? For example, when using the Loop script step,
you must decide whether the loop starts at the first or last record, a specific record, or the
current record in the
found set. (Use the Go to Record/Request/Page script step, Go to
Related Record script step, or Go to Portal Row script step to specify a starting record. If
you don't include a navigation script step to determine the current record, the loop begins
with the record that's current when the script is performed.)