<choose>

<choose> evaluates ordered <when> arms and falls back to one final <otherwise> arm.

Why use it

Use it when workflow routing depends on a durable boolean value and truthy coercion would be unsafe or ambiguous.

Common use cases

  • Choose approved or rejected processing.
  • Route eligible and ineligible records.
  • Publish one path-stable result from conditional branches.

Syntax

WOML
<choose id="route">
  <when test="{{context.steps.isApproved}}">
    <step id="approved"><script>return { status: "approved" };</script></step>
    <result value="{{context.steps.approved}}" />
  </when>
  <otherwise>
    <step id="rejected"><script>return { status: "rejected" };</script></step>
    <result value="{{context.steps.rejected}}" />
  </otherwise>
</choose>

Rules and behavior

  • One or more ordered <when> arms and exactly one final <otherwise> are required.
  • test is one exact context reference whose runtime value must be a JSON boolean.
  • The first true <when> wins.
  • With an id, every arm ends in <result> and the selected value becomes context.steps.<chooseId>.
  • Without an id, arms omit <result> and the choice publishes no merged output.