Run a script with another request

To run a FileMaker script as part of another request, include the script.prerequest, script.presort, and script parameters in the request body.

Parameter

Value

script

The name of the script to be run after the action specified by the API call (get, create, edit, duplicate, delete, find) and after the subsequent sort.

script.param

The text string to use as a parameter for the script that was named by script.

script.prerequest The name of the script to be run before the action specified by the API call and the subsequent sort.
script.prerequest.param The text string to use as a parameter for the script that was named by script.prerequest.
script.presort The name of the script to be run after the action specified by the API call but before the subsequent sort.
script.presort.param The text string to use as a parameter for the script that was named by script.presort.

Script execution order

You can specify the script.prerequest, script.presort, and script parameters on a single API call. Each keyword can be specified only once. The host processes these parameters as part of the API call in this order:

  1. Go to the layout specified in the URL.

  2. Perform the script named by script.prerequest, if specified.

  3. Perform the action specified by the API call (get, create, edit, duplicate, delete, find).

  4. Perform the script named by script.presort, if specified.

  5. Perform the sort specified on the API call:

  6. Perform the script named by script, if specified.

  7. Return the result set for the API call, with the offset and limit parameters applied, if specified.

Notes 

  • For calls that use HTTP GET and HTTP DELETE methods, the scripting parameters are included as URL parameters; see Get a single record, Get a range of records, and Delete a record.

    For example:

    https://<host>/fmi/data/v1/databases/customers/layouts/entry/records/14?script=UpdateProcessing&script.param=14

  • For calls that use HTTP POST and HTTP PATCH methods, the scripting parameters are included in the request body; see Create a record, Edit a record, and Perform a find request request.

    For example:

    {"query":[{"Title":"Office Manager"}], "script.prerequest":"Eliminate duplicates"}

  • For the script parameters script.param, script.prerequest.param, and script.presort.param, you may specify only a single text string. To pass in multiple parameters, you can create a string delimiting the parameters and have your script parse out the individual parameters. For example, pass "param1|param2|param3" as a list with the "|" character URL-encoded as: param1%7Cparam2%7Cparam3

  • Script results are returned using the scriptResult, scriptResult.prerequest, and scriptResult.presort parameters in the JSON data. Script errors are returned using the scriptError, scriptError.prerequest, and scriptError.presort parameters in the JSON data. (Script errors are not returned using an HTTP status code.)