Perform Script On Server

Performs a script specified from a list or calculated by name on the server that is hosting the current file.

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.
  • Wait for completion pauses the script on the client until the sub-script called by Perform Script On Server is completed on the host. Wait for completion must be selected to pass a script result or error code from the host to the client. Use the Get(ScriptResult) function to capture a result or the Get(LastError) function to capture an error code.

Compatibility 

Product Supported
FileMaker Pro Yes
FileMaker Go Yes
FileMaker WebDirect Yes
FileMaker Server No
FileMaker Cloud products No
FileMaker Data API Yes
Custom Web Publishing Yes

Originated in version 

13.0

Description 

The current file must be hosted on FileMaker Server or a FileMaker Cloud product. Otherwise, Perform Script On Server returns an error. See About running scripts on FileMaker Server and FileMaker Cloud products.

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.

Example 1 

Runs a script on the server and sends the current layout name, customer ID, and customer email address as the script parameter. The server navigates to the layout and record specified in the parameter, saves a snapshot link of the current record, emails the snapshot link to the email address specified in the parameter, and returns a result. The client fetches the script result from the server and displays it in a custom dialog box.

Main script: Email snapshot link (Client)

Copy
Perform Script on Server [Specified: From list ; "Email snapshot link (Server)" ; Parameter: List ( Get ( LayoutName ) ; Customers::ID ; Customers::Email ) ; Wait for completion: On]
Show Custom Dialog [Get ( ScriptResult )]

Sub-script: Email snapshot link (Server)

Copy
Go to Layout [GetValue ( Get ( ScriptParameter ) ; 1 )]
Enter Find Mode [Pause: Off]
Set Field [Customers::ID; GetValue ( Get ( ScriptParameter ) ; 2 )]
Perform Find [ ]
Set Variable [$PATH; Value:Get ( TemporaryPath ) & "Snapshot.fmpsl"]
Save Records as Snapshot Link ["$PATH"; Current record ; Create folders: Off]
Send Mail [Send via SMTP Server; With dialog: Off; To: GetValue ( Get ( ScriptParameter ) ; 3 ); "$PATH"]
Exit Script [Text Result: "Snapshot link sent."]