5/7

XOR: check that an order is either delivered or collected

Medium

At checkout a customer chooses how to get their order: home delivery, or collection from the store. It has to be exactly one. Return the message the checkout shows:

  • exactly one chosen — "OK"
  • both chosen — "Choose delivery or collection, not both"
  • neither chosen — "Choose delivery or collection"

Appian has no xor() function. Build "exactly one" from what it does have, then tell the two problems apart.

Inputs

  • ri!delivery — Boolean
  • ri!collection — Boolean

ri! Rule Inputs

ri!deliveryBoolean
true
ri!collectionBoolean
false

Example 1 — Delivery only

Input: ri!delivery
true
Input: ri!collection
false
Output:
"OK"

Example 2 — Collection only

Input: ri!delivery
false
Input: ri!collection
true
Output:
"OK"

Example 3 — Both chosen

Input: ri!delivery
true
Input: ri!collection
true
Output:
"Choose delivery or collection, not both"

Example 4 — Neither chosen

Input: ri!delivery
false
Input: ri!collection
false
Output:
"Choose delivery or collection"

Appian Expression Tips

  • • Use ri!variableName for rule inputs
  • • Use a!localVariables(local!x: …, body) for locals
  • • Use a!forEach(items: …, expression: fv!item) to iterate
  • • Use where() / reject(fn!isnull, list) to filter