BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
12 / 81 · Module 6 — Mule Routing and Orchestration · filtered: interview← prev⊞ allnext →

6.2Choice

Choice is Mule's equivalent of:

if (...) {
   ...
} else if (...) {
   ...
} else {
   ...
}

Example requirement:

Premium customers go through one Salesforce process, standard customers another.

Conceptually:

Choice
  │
  ├── when customerType == "Premium"
  │       ↓
  │    premium flow
  │
  ├── when customerType == "Standard"
  │       ↓
  │    standard flow
  │
  └── otherwise
          ↓
       error/default

Mule XML conceptually:

<choice>

    <when expression="#[payload.customerType == 'Premium']">
        ...
    </when>

    <when expression="#[payload.customerType == 'Standard']">
        ...
    </when>

    <otherwise>
        ...
    </otherwise>

</choice>

The expression is DataWeave.