Perform Script On Server with Callback
Performs a script on the server that is hosting the current file without pausing the client and performs the specified callback script on the client when the server script is done.
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.
-
Callback script specified is the script to run on the client after the script is completed on the server. Choose:
-
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 callback script.
-
State specifies how to handle a currently running script when the callback script is run. The options are Continue, Halt, Exit, Resume, and Pause. See Options for handling the current script when starting new scripts.
Compatibility
Product | Supported |
---|---|
FileMaker Pro |
Yes |
FileMaker Go |
Yes |
FileMaker WebDirect |
Yes |
FileMaker Server |
No |
FileMaker Cloud |
No |
FileMaker Data API |
No |
Custom Web Publishing |
No |
Originated in version
20.1
Description
The current file must be hosted on FileMaker Server or FileMaker Cloud. Otherwise, this script step returns an error. See About running scripts on FileMaker Server and FileMaker Cloud.
The callback script is scheduled to run on the client after any current script has been completed, just like scripts that are triggered by the Install OnTimer Script script step and the OnWindowTransaction script trigger. The context in which the script runs is unknown and cannot be depended on to be the same as when this script step was executed. If needed, use the callback script's parameter to pass back enough context for it to run as expected on the client, such as the layout and found set to use.
Note If you specify a calculation as a parameter in the callback script, the calculation will be evaluated when the callback script runs on the client.
In the below example, nothing would be returned because $data does not exist when the callback script is executed on the client.
-
Caller
Set Variable [ $data ; Value: 1 ]
Perform Script on Server with Callback [ Specified: From list ; "Test" ; Parameter: ; Callback script specified: From list ; "Callback" ; Parameter: $data ; State: Continue ]
-
Test
Set Variable [ $data ; Value: 2 ]
-
Callback
Set Variable [ $param ; Value: Get ( ScriptParameter ) ]
Show Custom Dialog [ $param ]
Notes
-
The callback script will not be called in the following scenarios:
-
The server or client quits unexpectedly.
-
The user quits the client or closes the file before the script on the server is completed.
-
The network connection is lost while the script step is being executed. However, reconnecting within 10 minutes after the server script is completed causes the callback script to be executed.
-
-
Multiple instances of this script step can be run consecutively. The callback scripts run in the order that these script steps complete.
-
If a callback script is not specified, this script step will run similarly to the Perform Script on Server script step.
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)
Perform Script on Server with Callback [ Specified: From list ; "Email snapshot link (Server)" ;
Parameter: List ( Get ( LayoutName ) ; Customers::ID ; Customers::Email ) ;
Callback script specified: From list ; "Complete message (Client)" ; Parameter: ; State: Continue ]
Sub-script: Email snapshot link (Server)
Go to Layout [ GetValue ( Get ( ScriptParameter ) ; 1 ) ; Animation: None ]
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 ; No dialog ; To: GetValue ( Get ( ScriptParameter ) ; 3 ) ; "$PATH" ]
Exit Script [ Text Result: "Snapshot link sent." ]
Callback script: Complete message (Client)
Show Custom Dialog [ Get ( ScriptResult ) ]