Loopfour
Blocks

Sub-Workflow block

Configure the Sub-Workflow block to call another workflow as a step, pass inputs to it and use the outputs it returns in later steps.

The Sub-Workflow block (type: "subworkflow") starts another workflow in your company as a child run, passes it an input, and by default waits for its result. For the plain-language guide, see Reuse one workflow inside another.

When to use it

  • Keep one "post a journal entry" workflow and call it from several month-end workflows.
  • Process each entity or customer in its own child run, so one failure does not hide the rest.
  • Split a large workflow into parts that can be tested and deployed on their own.

Configuration

Field (config key)Editor labelTypeRequiredMeaning
workflowIdWorkflowstringYesThe id of the workflow to run. It must belong to your company and be deployed (status active).
inputInput MappingobjectNoThe child run's input. Use template references, such as { "customerId": "{{steps.lookup.id}}" }. Must be an object; empty means {}.
waitForCompletionWait for CompletionbooleanNoDefault true. When false, the step starts the child and continues without its result.
timeoutMinutesTimeout (minutes)numberNoHow long to wait for the child. Default 5, at most 1440 (24 hours). Used only when waiting.
idempotencyKeyIdempotency KeystringNoA stable key, such as close-{{input.period}}-{{input.entityId}}. A second call with the same key reuses the existing child run instead of starting another. A failed or cancelled child with that key is started again.
queueNameQueue NamestringNoA named queue for child runs.
queueConcurrencyLimitQueue Concurrency LimitnumberNo1 to 20. The most child runs active in the queue at once, shared by every Sub-Workflow step in the company that uses the same queue name. Needs queueName.
machineCompute CapacitystringNostandard (default, the child's own setting), medium-1x, medium-2x or large-1x. Higher capacity costs more per minute of run time.
maxDurationSecondsTime Limit (seconds)numberNoThe child run's time limit, at least 5. Blank uses the child workflow's own limit.

Older workflows may hold inputMapping or timeout (milliseconds). These are moved to input and timeoutMinutes when the workflow is saved or run. If an old value disagrees with the new field, the editor shows it as Legacy Input Mapping or Legacy Timeout (milliseconds) and the run fails until you clear it.

Output

When the step waits:

FieldTypeMeaning
outputanyThe child run's output. Read it as {{steps.<step id>.output.<path>}}.
statusstringcompleted.
subworkflowIdstringThe child workflow id.
subworkflowRunIdstringThe child run id.
waitedForCompletionbooleantrue.
reusedExistingRunbooleantrue when an idempotency key matched an existing child run.
durationMsnumberTime spent waiting.

When waitForCompletion is false, the output has subworkflowId, subworkflowRunId, status (triggered, or the reused run's status), waitedForCompletion: false and reusedExistingRun.

The editor's output list shows result and runId; the executor returns output and subworkflowRunId. Here output is a field of this step's result, so {{steps.<step id>.output.<path>}} is correct for this block.

Example

This step runs a "Post accrual" workflow for each entity in a loop, keyed so a retry does not post twice.

{
  "id": "post_accrual",
  "type": "subworkflow",
  "name": "Post accrual for entity",
  "config": {
    "workflowId": "5b0d3c2a-1e4f-4a6b-8c9d-0e1f2a3b4c5d",
    "input": {
      "entityId": "{{variables.entity.id}}",
      "period": "{{input.period}}",
      "amount": "{{variables.entity.accrual}}"
    },
    "waitForCompletion": true,
    "timeoutMinutes": 15,
    "idempotencyKey": "accrual-{{input.period}}-{{variables.entity.id}}"
  }
}

Errors and limits

  • The step fails when the workflow is not found, not deployed, or belongs to another company.
  • The step fails when input is missing a field the child's inputSchema marks as required.
  • A failed or cancelled child run fails the step with the child's error. A child that does not finish within timeoutMinutes fails the step; the child keeps running.
  • The wait counts toward the parent run's time limit. If the parent is near its limit, the step fails and the child keeps running. Raise the parent's time limit, or turn Wait for Completion off.
  • queueConcurrencyLimit without queueName fails the step.
  • A {{secrets.KEY}} reference in a Sub-Workflow step's config stops the run before it starts. Reference the secret inside the child workflow instead.

On this page