Exit Script with result: structured return patterns
BeginnerReturn structured data from sub-scripts using Exit Script with JSON results, and consume them reliably in parent scripts.
What you'll learn
- How to return a plain string result from a sub-script
- How to encode a JSON object with multiple fields as the script result
- How to decode the JSON result in the parent script
- How to include a success/error flag in every result
- When to use Exit Script vs Halt Script
Every FileMaker script can return a single text value to its caller via Exit Script [ Text Result: expression ]. Because the result is always a string, encoding structured data as JSON lets you return multiple values, a status flag, and an error message in one compact payload. The parent reads it with Get(ScriptResult) immediately after the Perform Script step.
Return a simple status string
For simple yes/no outcomes, returning "success" or "error: <reason>" is sufficient. The parent checks the first word of Get(ScriptResult). Always exit via Exit Script, never Halt Script, when a parent is waiting -- Halt Script stops ALL scripts, not just the current one.
# Sub-script: Validate Email Set Variable [ $email ; Value: Get ( ScriptParameter ) ] If [ PatternCount ( $email ; "@" ) = 0 ] Exit Script [ Text Result: "error: missing @ symbol" ] End If If [ Length ( $email ) < 6 ] Exit Script [ Text Result: "error: address too short" ] End If Exit Script [ Text Result: "success" ]
Sign in to track your progress and pick up where you left off.
Sign in to FM Dojo