Database Reference
In-Depth Information
run properly. To solve this problem, use the GetFieldName() function. (It's in the Logical functions
section.)
GetFieldName ( Invoices::Due Date )
This formula returns the text value “Invoices::Due Date,” which may seem like extra work to ac-
complish the same thing. But using the function to pass the field name instead of static text ensures
that if you ever rename the field, FileMaker corrects the formula for you, and your script keeps
working properly. If you ever want to pass the name of a field as a script parameter (or otherwise
refer to a field's name directly in a calculation), use GetFieldName() to protect against name
changes.
Script Parameters
When you call a script by using the Perform Script step or attach the script to a button, the
Specify Script window shows a box labeled “Optional script parameter.” You can type a stat-
ic value in the box, or you can click Edit to create a dynamic calculation that FileMaker eval-
uates when the script starts to run. FileMaker stores the value, and you can check it anywhere
inside the script with the Get(ScriptParameter) function and then branch the script based
on the result.
For example, you might make a script that can sort records in three different ways. That way,
three different buttons can run the same script, with three different results. The script para-
meter that's attached to each button tells the script which sort order to use. The benefit is
similar to modular scripting: If this process has to change later, you have only one script to
change and one new button to create. This technique can drastically reduce the number of
scripts you have to write.
NOTE
Script parameters don't automatically pass on to subscripts. If the subscript needs to know what's in
your main script's parameters, use Get(ScriptParameter) as the subscript's optional parameter.
Suppose you want buttons on the Customer List layout to sort your Customer records by
Name, City, or State. You can get the job done with just one script:
1. Create a new script called Sort Customer List .
This script will handle a few common sorts, but you start with a branch.
2. Add the If step to the script .
Search WWH ::




Custom Search