Help

Table Of Contents
Creating scripts to automate tasks
F
ILEMAKER PRO HELP 420
Which window do you want to use? A script is initially attached to a specific window, which
may be in the background. The script remains on that window until a scripted action
switches to another window. For example, use the
Select Window script step to specify a
different window. If the specified window is not available, the script switches to the
foreground window of the file. When you pause a script, the associated window becomes
the foreground window if it is available.
Should the script switch among modes? A script can be run from Browse, Find, Layout, or
Preview modes. Make sure your script is in the proper mode before it acts upon something.
For example, use the
Enter Browse Mode script step to modify data in fields and records,
and use the Enter Find Mode script step to set up or perform a find request.
Note Scripts performed in Layout mode automatically switch to Browse mode before executing.
Which fields and layouts will the script need? Some steps (such as the Go to Field script
step and the Insert Text script step) require a field to be on the current layout, while others
(such as the Set Field script step) don’t. Either use the Go to Layout script step to switch to
a layout that has the fields your script requires, or place the fields on the gray area to the
right of the layout to make the fields available for script steps but not to users.
Should the records be processed in a certain order? Decide among the current sort order, a
specified sort order, or unsorted (the order in which the records were created). Use the Sort
Records script step or the Unsort Records script step before entering a loop to order your
records properly before processing them.
How should the script advance through multiple fields or records? (Use the Go to Record/
Request/Page script step, the Loop script step, the Exit Loop If script step and the End Loop
script step to control multiple field or record processing).
When should the script finish? After all script steps have run? After a specified condition has
been met? (Use the
If script step, the Else If script step, and the Else script step to perform
a task such as the Exit Script script step when the script reaches a specified condition.)
How will you test your script? Use the Pause/Resume Script script step to pause at
predefined points in your script. Save a copy of your database, and then define and test
your script in it to preserve the original data.
Note If you are using FileMaker Pro Advanced, you can use the Script Debugger to test and
troubleshoot your scripts.
How will you handle error conditions (such as an empty found set)? You can capture the last
error condition reported by FileMaker
Pro by using the Get(LastError) function. Use this
function and the If script step, the Else If script step, and the Else script step to create
scripts that react gracefully to user errors or unexpected results. For even greater control,
use the
Set Error Capture script step to suppress the error alerts that FileMaker Pro
normally displays in these situations, and replace them with your own using the Show
Custom Dialog script step.
Should all users be allowed to perform all scripts? Use privilege sets to control users’
access to scripting. Through the use of privilege sets, users can be allowed to execute or
modify individual scripts, no scripts, or all scripts. You can also set the default permission for
each privileges set for any future new scripts that are defined in the file. Setting a script to
run with full access privileges will allow the script to do things on behalf of the user that may
not be normally allowed by their assigned privileges. See
Creating and managing privilege
sets.
How will users perform the script? You either need to create a button to perform the script or
specify that the script be added to the Scripts menu. Scripts can also be run from the
Manage Scripts dialog box or when a
script trigger is activated. For example, you can use
the OnFirstWindowOpen script trigger to run a script when the database opens.