Automating tasks with scripts > Creating and editing scripts
 

Creating and editing scripts

Note  For information on each script step, its options, and examples, see Script steps reference (alphabetical list) and Script steps reference (category list). Also see Script examples.

To create or edit a script:

1. Choose Scripts menu > Script Workspace.

Or, choose File menu > Manage > Scripts.

The Script Workspace opens. You create and edit scripts using the three panes in this window—the scripts pane (left), the script editing pane (center), and the script steps pane (right).

2. Create or open a script:

To create a script, click New Script button. In the script editing pane, type a name for the new script and press Enter or Return.

To preview a script, click the script name in the scripts pane. Click Switch to Edit button to switch from previewing to editing the script.

To edit a script, double-click the script name in the scripts pane. If the script is already open in the script editing pane, click the script's tab to make it active.

3. Begin typing a script step name, then choose the script step from the list that appears.

Or, double-click the script step in the script steps pane.

4. If the script step has options—indicated by text enclosed in brackets ([ ]) or by Action menu button next to the script step—do one of the following:

Click the text in the brackets, then specify options that appear.

Click Action menu button, then specify options that appear.

Click between the brackets and edit the calculation, or click Calculation button to open the Specify Calculation dialog box. Only some calculations are editable inline.

Note  As you edit a script step, you may see the Restore option. Restore indicates that the criteria you specified when the script step was last edited will be used when the script step is executed.

5. Do any of the following as you work in the script editing pane:

 

To

Do this

Add a line to the script

Do one of the following:

Press Enter or Return.

If the last line of the script is not blank, select the last line and press Down Arrow.

Add a line above the selected line

Press Shift+Enter or Shift-Return.

Move between lines in the script

Press Up Arrow or Down Arrow.

Add a comment to a script

On a blank line, type # or choose Comment from the script steps pane. Using the # (Comment) script step in your script helps others who view or modify it.

Add a script step to the Favorites category

In the script steps pane, select the script step and click Gray star button. To remove a script step from the Favorites category, select the script step and click Blue star button.

Note  You can't add a script step to the Favorites category if the script steps pane is sorted alphabetically.

View information about a script step

In the script steps pane, click the script step. A description appears below the list. To view more information, click Help button.

View script steps alphabetically or by category

In the script steps pane, click Alphabetical sort button to display script steps alphabetically, or click Category sort button to list by category.

See which FileMaker products support a script step

Click Compatibility button and choose a product. All scripts steps that are compatible with the product are displayed.

Copy and paste a script step

See Copying and pasting scripts.

Duplicate a script step

Select the script step, then choose Edit menu > Duplicate (Windows) or Duplicate Step (macOS).

Delete a script step

Select the script step, then press Delete.

Reorder the script steps in the script

Drag the script step in the script editing pane to a new location in the script.

Select multiple script steps

Press Ctrl-click (Windows) or Command-click (macOS). You can add, duplicate, or delete multiple steps.

Open a script that is included in a script step option

Ctrl-click (Windows) or Command-click (macOS) the script step option.

Run the script

Click Run Script button.

Note  An asterisk (*) next to a script name means that the script has been changed but not saved.

6. Close the tab, then click Save.

Or, choose File menu > Save Script in the Script Workspace (Windows), or choose Scripts menu > Save Script in the FileMaker Pro Advanced menu bar (macOS).

To manage scripts:

 

To

Do this

Rename, duplicate, or delete a script

Right-click the script name and choose from the menu. You can also click the script name in the script editing pane twice to rename a script.

Reorder the scripts

Drag the script name to a new location in the list.

Print a script

Windows: In the Script Workspace, choose File menu > Print Script.

macOS: In the FileMaker Pro Advanced menu bar, choose File menu > Print.

Perform a script with full access privileges

Right-click the script and choose Grant Full Access Privileges. See "Running scripts with full access privileges," below.

Manage folders in the scripts pane

See Managing scripts using folders.

Running scripts with full access privileges

Setting a script to run with full access privileges allows users with limited access and privileges to perform scripted tasks that they are otherwise unable to perform, such as exporting or deleting records.

The access privileges do not change, but the script is allowed more privileges than the user is. Furthermore, full access does not carry over to any subsequent sub-script, unless this feature has been enabled in that script as well.

Scripts can be set to run with full access privileges only by users with the Full Access privilege set. Only users with full access privileges can edit or delete scripts for which this feature has been enabled.

A script can run with full access privileges only in the file in which the script is defined. Scripts cannot override access restrictions on external files. For example, a script that is set to run with full access privileges cannot delete records in an access-restricted external file.

Users without full access privileges can be given permission to edit scripts that are marked as modifiable in their assigned privilege set. Full access privileges are required to create, duplicate, import, and/or delete scripts.

Notes 

To check for problems as you build a script, right-click the tab in the script editing pane and choose Check for Problems. FileMaker Pro Advanced checks the script and highlights lines with problems, such as missing options. (Not every problem can be detected.) Lines are highlighted in the default Problem color in the Syntax Coloring tab of the Script Workspace preferences.

To edit the color coding of script steps and conditions such as problems, in the Script Workspace, choose View menu > Preferences (Windows) or View menu > Script Workspace Preferences (macOS) and click the Syntax Coloring tab.

To edit a script in a new window, right-click a tab in the script editing pane and choose Move Tab to New Window, or press Alt (Windows) or Option (macOS) and double-click a script in the scripts pane. The script opens in the Edit Script dialog box.

To allow the script to run with full access privileges, choose File menu > Grant Full Access Privileges (Windows) or Scripts menu > Grant Full Access Privileges (macOS).

If you accessed the Edit Script dialog box by converting a button action to a script, you can press Ctrl+R (Windows) or Command-R (macOS) to rename the script.

Related topics 

Using operators in formulas

Script steps reference (category list)

Script steps reference (alphabetical list)

Working with buttons and button bars on layouts

Working with the Scripts menu

Editing scripts privileges

Publishing databases on the web

Debugging scripts

Disabling script steps