BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
939 / 1048 · Module 18 — Interview Coding Scenarios← prev⊞ allnext →

18.14Scenario 13 — More than two Choice branches

<choice>

    <when expression="#[payload.operation == 'CREATE']">
        <flow-ref name="create-customer"/>
    </when>

    <when expression="#[payload.operation == 'UPDATE']">
        <flow-ref name="update-customer"/>
    </when>

    <when expression="#[payload.operation == 'DELETE']">
        <flow-ref name="deactivate-customer"/>
    </when>

    <otherwise>
        <raise-error
            type="APP:INVALID_OPERATION"/>
    </otherwise>

</choice>

But if CREATE and UPDATE can both use:

Upsert

you should question whether separate branches are needed.

Good interview comment:

“I wouldn't create separate CREATE and UPDATE branches if Salesforce Upsert already models the business requirement.”