Skip to content

Switch State

- id: a
  type: switch
  defaultTransform: 'jq(del(.x))'
  defaultTransition: b
  conditions:
  - condition: 'jq(.y == true)'
    transform: 'jq(.x)'
    transition: c
  - condition: 'jq(.z == true)'
    transform: 'jq(.x)'
    transition: d

SwitchStateDefinition

To change the behaviour of a workflow based on the instance data, use a switch state. This state does nothing except choose between any number of different possible state transitions.

Parameter Description Type Required
type Identifies which kind of StateDefinition is being used. In this case it must be set to switch. string yes
id An identifier unique within the workflow to this one state. string yes
log If defined, the workflow will generate a log when it commences this state. See StateLogging. Structured JQ no
metadata If defined, updates the instance's metadata. See InstanceMetadata. Structured JQ no
defaultTransform If defined, modifies the instance's data upon completing the state logic. But only if none of the conditions are met. See StateTransforms. Structured JQ no
defaultTransition Identifies which state to transition to next, referring to the next state's unique id. If undefined, this state terminates the workflow. But only if none of the conditions are met. string no
catch Defines behaviour for handling of catchable errors. []ErrorCatchDefinition no
conditions List of conditions, which are evaluated in-order until a match is found. []SwitchConditionDefinition yes

SwitchConditionDefinition

Parameter Description Type Required
condition Selects or generates the data used to determine if condition is met. The condition is considered met if the result is anything other than null, false, {}, [], "", or 0. Structured JQ yes
transform If defined, modifies the instance's data upon completing the state logic. See StateTransforms. Structured JQ no
transition Identifies which state to transition to next, referring to the next state's unique id. If undefined, matching this condition terminates the workflow. string no