Exit Script [Result] and reading results with Get(ScriptResult)

Intermediate

FileMaker scripts can return a single value to their caller using Exit Script [Result]. Learn how to return structured JSON results, read them with Get(ScriptResult), and establish a consistent success/error pattern.

What you'll learn

  • How Exit Script [ Result ] returns a value to the calling script
  • How to read the result with Get(ScriptResult) in the caller
  • A JSON result pattern for returning both status and data

Exit Script [ Result ] passes a single text value back to the script that called this one — using JSON as the result format enables returning multiple values and a clear success/error contract.

1/2
1

Return a result from a sub-script

Use Exit Script [ Result ] at the end of your script. For a simple success/failure, return True or an error code. For richer responses, return a JSON object.

FileMaker Script
# Sub-script: "Fetch Customer"
Set Error Capture [ On ]
Allow User Abort [ Off ]

Set Variable [ $id ; Value: JSONGetElement ( Get ( ScriptParameter ) ; "id" ) ]

# ... perform find for this customer ...

If [ $error ≠ 0 ]
  Exit Script [ Result:
    JSONSetElement ( "{}" ;
      [ "success" ; False          ; JSONBoolean ] ;
      [ "error"   ; $error         ; JSONNumber  ] ;
      [ "message" ; "Record not found" ; JSONString ]
    )
  ]
End If

Exit Script [ Result:
  JSONSetElement ( "{}" ;
    [ "success" ; True                ; JSONBoolean ] ;
    [ "id"      ; Customers::id      ; JSONNumber  ] ;
    [ "name"    ; Customers::fullName ; JSONString  ]
  )
]

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

Sign in to FM Dojo