Skip to main content
2/5

a!match(): choose a parcel size from its weight

Medium

A courier's booking form sizes each parcel from its weight in kilograms:

  • up to 1 kg is "Small parcel"
  • over 1, up to 5 kg is "Medium parcel"
  • over 5, up to 20 kg is "Large parcel"
  • over 20 kg is "Freight"

A weight of 0 or less is a typing mistake and must come back as "Invalid weight", not as a small parcel. The first whenTrue that holds wins, so think about which band has to be checked first.

Input

  • ri!weight: Decimal

ri! Rule Inputs

ri!weightDecimal
2.5

Example 1: Light enough for small

Input: ri!weight
0.5
Output:
"Small parcel"

Example 2: Exactly 1 kg is still small

Input: ri!weight
1
Output:
"Small parcel"

Example 3: Just over the small band

Input: ri!weight
1.2
Output:
"Medium parcel"

Example 4: Exactly 20 kg is still large

Input: ri!weight
20
Output:
"Large parcel"

Example 5: Too heavy for a parcel

Input: ri!weight
35
Output:
"Freight"

Example 6: Zero is a mistake

Input: ri!weight
0
Output:
"Invalid weight"

Example 7: Negative is a mistake

Input: ri!weight
-2
Output:
"Invalid weight"

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