Perform Script
Performs a script specified from a list or calculated by name.
See also
Options
- Specified:
- From list allows you to select the script you want to perform.
- By name allows you to specify the script name by a calculation. The script name is not case sensitive.
- Parameter specifies a script parameter for the specified script.
Compatibility
Product | Supported |
FileMaker Pro | Yes |
FileMaker Go | Yes |
FileMaker WebDirect | Yes |
FileMaker Server | Yes |
FileMaker Cloud | Yes |
FileMaker Data API | Yes |
Custom Web Publishing | Yes |
Originated in version
6.0 or earlier
Description
There is no need to open an external file when using a script in it—FileMaker Pro opens it for you.
You can use separate scripts to break complex tasks into smaller segments, which are often easier to troubleshoot. You can also save time by putting common tasks like printing or exporting records into separate scripts, which can then be accessed by more than one script. For example, you might want to use the same page setup and printing options in several scripts. By defining those steps once and saving them in separate scripts, you make it easy to access those steps many times.
Use script parameters to pass text or numbers into a script. When a parameter is specified, that parameter may be accessed within a script or passed to other script steps using the Get(ScriptParameter) function.
Script parameters:
- exist within the parent script only unless explicitly passed to the sub-script. If your script calls another script, parameters in the called script are independent of parameters in the parent script.
- exist only for the duration of the script. Script parameters are reset each time a script is performed.
- can be used (but not modified) within a script and can be passed along to sub-scripts by using the Get(ScriptParameter) function as the parameter for the sub-script. You can also specify different parameters each time the sub-script is called using Perform Script. Changing the parameters passed to a sub-script does not modify the value of the parameters returned from Get(ScriptParameter) in the parent script.
- can contain multiple values separated by carriage returns. Use the LeftValues function, MiddleValues function, and RightValues function to isolate a specific parameter.
Tip If you've performed an external script and you want to return to the original file, add an Enter Browse Mode step or Go to Layout step right after the Perform Script step in the original file, so that the script returns to the original file.
Notes
- If you use By name to specify a script in another FileMaker Pro file, the calculation must evaluate to <data source name>::<script name>, such as "Invoices::Do Quarterly Billing." Both data source and script names are case sensitive.
- If you are defining a custom menu item that performs a script, select the script and optional script parameters. See Defining custom menus.
- For scripts run via FileMaker WebDirect, the FileMaker Data API, and Custom Web Publishing, the files containing the scripts must be on the same host and have the appropriate extended privileges enabled to permit access. See Editing extended privileges for a privilege set.
Example 1
Runs the "Print Invoice Report" script with no parameters.
Go to Layout ["Invoice Report"]
Perform Script [Specified: From list; "Print Invoice Report"; Parameter: ]
Example 2
Uses a field value, Customer Name, as the parameter. Invoices for the current customer are returned in a new window with the Invoice Report layout.
Main script: Current Customer Invoices
Find Matching Records [Replace; Invoices::Customer ID]
#Calls the "View Customer Invoices" sub-script defined below
Perform Script [Specified: From list; "View Customer Invoices"; Parameter: Invoices::Customer Name]
Sub-script: View Customer Invoices
New Window [Style: Document; Name: "Customer: " & Get ( ScriptParameter ); Using layout: "Invoice Report" (Invoices)]
Sort Records [Restore; With dialog: Off]
Example 3
Shows a custom dialog box with the default button and button 2, then performs the script named "Button1" or "Button2" depending on the user's choice returned in Get ( LastMessageChoice ).
Show Custom Dialog [ "Do you want to continue?" ]
Perform Script [ Specified: By name ; "Button" & Get ( LastMessageChoice ) ; Parameter: ]