bmel:switch¶
Category: Logic & Control Flow · Returns: bmel:any
Signature
bmel:switch(subject: bmel:any, case: bmel:any, result: bmel:expression, otherwise: bmel:expression)
Description¶
Evaluates bmel:subject against one or more case/result pairs (left to right) and returns the result of the first matching case. Case/result pairs can be repeated: bmel:switch(subject, case1, result1, case2, result2, …, bmel:otherwise?). If no case matches, returns bmel:otherwise or null if omitted. Equivalent to Java switch/SQL DECODE.
Arguments¶
| Parameter | Type | Required | Description |
|---|---|---|---|
subject | bmel:any | The expression or field value to match against each case. | |
case | bmel:any | A candidate value to compare against bmel:subject using strict equality. Repeat case/result pairs for additional branches. | |
result | bmel:expression | Expression returned when bmel:subject equals the immediately preceding bmel:case value. | |
otherwise | bmel:expression | Fallback expression returned when no case matches bmel:subject. Returns null if omitted. |
Examples¶
Channel label from a code
bmel:switch({createOrder:Request Payload}.$.channel, 'W', 'Web', 'M', 'Mobile', 'Other')
Priority from the status
bmel:switch({getOrder:Response Payload}.$.status, 'FAILED', 1, 'PENDING', 2, 3)