How to pass a JSON parameter to a FileMaker script

Intermediate

Script parameters are a single text value. Learn why JSON is the right way to pass multiple values, and how to read them back inside a script.

What you'll learn

  • Why FileMaker scripts only have one parameter, and how to work with that
  • How to pass multiple values using a JSON object as the parameter
  • How to read individual values inside the script with JSONGetElement

Every FileMaker script receives exactly one parameter — a text string. When you need to pass more than one value, the pattern is to encode them as a JSON object and decode them inside the script using JSONGetElement.

1/3
1

Pass a JSON object as the script parameter

When calling a script, build a JSON object using JSONSetElement and pass it as the parameter. Each key is a named argument.

FileMaker Script
# Build the parameter
Set Variable [ $param ; Value:
  JSONSetElement ( "{}" ;
    [ "customerId" ; Customers::id ; JSONNumber ] ;
    [ "mode"       ; "edit"         ; JSONString ]
  )
]

Perform Script [ "Update Customer" ; Parameter: $param ]

Sign in to track your progress and pick up where you left off.

Sign in to FM Dojo