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.

Options 

  • Script is the script to run on the server.

  • Callback Script is the script to run on the client after the server script is completed on the server.

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 [ Script: "Test" ; Callback script: "Callback" ; Parameter: $data ]

  • Test

    • Set Variable [ $data ; Value: 2 ]

  • Callback

    • Set Variable [ $param ; Value: Get ( ScriptParameter ) ]

    • Show Custom Dialog [ $param ]

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 with Callback [ Script: "Email snapshot link (Server)" ; Parameter: List ( Get ( LayoutName ) ; Customers::ID ; Customers::Email ) ; Callback script: "Complete message (Client)" ]

Sub-script: Email snapshot link (Server)

Copy
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)

Copy
Show Custom Dialog [ Get ( ScriptResult ) ]

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.