Return Values and Exit Subflow Early (Return Subflow) in RunMacro
Desktop ModeBrowser ModeRunMacro RunnerRunMacro 3.5+
Return Subflow immediately exits the active subflow, evaluates declared return values, and yields execution control back to the calling workflow frame.
Dialog & quick setup

- Switch to the target Subflow tab (do not place in the Main flow).
- At the early exit point (typically within an IF block), add Control Flow › Return Subflow.
- In the Output Return Values table, declared output variables for this subflow will appear automatically.
- Enter literal values (numbers/strings/booleans) or variable tokens (e.g.,
{status_code},true,"success") into the Return Value column. - Click Save. During execution, reaching this command instantly stops the subflow and returns values to the caller.
Options reference
Modes & when to use
Desktop Mode
Exits the active desktop subflow frame and returns to the caller.
Browser Mode
Exits the browser subflow frame without closing the underlying Chrome/CDP session.
RunMacro Runner
The runner cleanly pops the local call frame and continues the caller sequence.
Best for
- Exiting early when encountering invalid arguments or unexpected conditions (e.g. IF {user} is empty -> Return {status} = "invalid_input").
- Short-circuiting out of subflow search loops as soon as a match is discovered (e.g. found matching item -> Return {found} = true).
- Explicitly assigning distinct output return values across multiple branching execution paths.
Use an alternative when
- Placing directly in the Main flow because Main flow has no caller frame.
- Breaking out of a simple loop while wanting to keep executing subsequent subflow steps.
- Subflows that execute linearly to the end without branching early.
Before you run
- The command must be placed inside a Subflow body never in the Main flow.
- The subflow has declared corresponding outputs if specific return values are to be evaluated.
- Source variables referenced in return expressions must exist and be valid when Return executes.
Example workflow
Example: Short-circuit on permission check failure
- Inside Subflow "CheckAccount", insert IF condition: {is_locked} == true.
- Inside the IF block, place Return Subflow: {status} = "blocked", {can_proceed} = false.
- Subsequent heavy actions (opening web sessions, querying APIs) are skipped entirely.
- The caller receives the result and can alert the operator immediately.
Example: Fast return from an item search loop
- Inside a For Each loop within a Subflow, check IF {item_id} == {target_id}.
- Add Return Subflow: {found} = true, {matched_index} = {index}.
- The subflow terminates immediately, returning the result to the caller without iterating remaining items.
- The caller reads the {found} variable to proceed with order updates.
Expected result: The subflow halts execution immediately at the Return Subflow step outputs are evaluated and caller advances.
Tips & limitations
Use Return Subflow near the top of subflows within IF blocks (guard clause pattern) to handle edge cases early and keep logic flat.
Never place Return Subflow in the Main flow. Executing it in the Main flow triggers an error ("subflow.invalid_return_in_main") and halts execution.
If a subflow finishes its last command without encountering Return Subflow, it automatically completes and returns the current values of declared output variables.
- Cannot be executed inside the Main flow doing so raises subflow invalid return in main.
- Only returns values for outputs declared in the Subflow Interface undeclared outputs cannot be dynamically introduced.
- Once Return Subflow triggers all subsequent commands within current subflow frame are bypassed.
- Referencing undefined variable tokens in return value fields causes a missing variable error.
- Return types must adhere to declared output schemas.
- It does not replace Stop Macro Return Subflow exits only active subflow not entire automation project.
Applies to RunMacro 3.5+ · Desktop Mode & Browser Mode & RunMacro Runner · Windows 10/11
