Choices and switches

Use <choose> for strict boolean decisions. Complex expressions belong in a preceding script step.

WOML
<choose id="route" name="Select 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>

Result-producing profile:

  • <choose> requires id; name and description are optional.
  • One or more ordered <when> arms are required.
  • Exactly one final <otherwise> is required.
  • Each arm has one or more flow items followed by exactly one <result>.
  • test must be one exact context reference whose runtime value is a JSON boolean. WOML does not coerce truthy values.
  • The first true <when> wins; otherwise the fallback runs.
  • The selected <result> value is published at context.steps.<chooseId>, giving later steps one predictable output.

Control-only profile:

  • Omit the id.
  • Arms are non-empty and omit <result>.
  • The choice controls execution but publishes no merged output.

<switch>, <case>, and <default>

Use <switch> for exact string routing:

WOML
<switch id="delivery" value="{{context.steps.order.provider}}">
  <case value="express">
    <step id="express"><script>return { days: 1 };</script></step>
    <result value="{{context.steps.express}}" />
  </case>
  <case value="standard">
    <step id="standard"><script>return { days: 5 };</script></step>
    <result value="{{context.steps.standard}}" />
  </case>
  <default>
    <step id="unsupported"><script>return { supported: false };</script></step>
    <result value="{{context.steps.unsupported}}" />
  </default>
</switch>
AttributeRequiredMeaning
valueYesOne exact context reference; runtime value must be a string.
idNoWhen present, enables a merged result at context.steps.<id>.
name, descriptionNoAvailable with the result-producing profile.

There must be one or more unique non-empty <case value="..."> arms and one final <default>. Matching is exact, ordered, case-sensitive, and performs no trim or coercion. There is no fallthrough. An ID-less switch has no <result>; an ID-bearing switch requires exactly one final <result> in every arm.