Sub-scripts: calling scripts from scripts in FileMaker

Intermediate

Breaking logic into reusable sub-scripts is the foundation of maintainable FileMaker development. Learn the parameter/result pattern, how to call sub-scripts, and how to structure a multi-script workflow.

What you'll learn

  • How to call a sub-script with a JSON parameter
  • How to read the sub-script result and handle errors in the caller
  • How to structure a workflow as an orchestrator script calling focused sub-scripts

Sub-scripts are ordinary scripts called from another script using Perform Script — they receive a parameter, do focused work, and return a result, enabling reuse and separation of concerns.

1/2
1

Call a sub-script with a parameter

Build a JSON parameter and pass it to Perform Script. The sub-script receives it via Get(ScriptParameter).

FileMaker Script
Set Variable [ $param ; Value:
  JSONSetElement ( "{}" ;
    [ "orderId" ; Orders::id   ; JSONNumber ] ;
    [ "action"  ; "recalculate" ; JSONString ]
  )
]

Perform Script [ "Manage Order" ; Parameter: $param ]

Set Variable [ $result  ; Value: Get ( ScriptResult ) ]
Set Variable [ $success ; Value: JSONGetElement ( $result ; "success" ) ]

If [ not $success ]
  Exit Script [ Result: $result ]  # propagate the error up
End If

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

Sign in to FM Dojo