1/5

a!forEach(): number a list of items

Easy

Turn a list of items into a numbered list. {"tea", "pie"} becomes {"1. tea", "2. pie"}.

Use a full stop and a single space after the number, exactly as shown.

Positions count from 1, not from 0.

Input

  • ri!items — List of Text

ri! Rule Inputs

ri!itemsList of Text
{
  "tea",
  "pie",
  "jam"
}

Example 1 — Three items

Input: ri!items
{
  "tea",
  "pie",
  "jam"
}
Output:
{
  "1. tea",
  "2. pie",
  "3. jam"
}

Example 2 — A single item still starts at 1

Input: ri!items
{"tea"}
Output:
{"1. tea"}

Example 3 — Nothing to number

Input: ri!items
{}
Output:
{}

Example 4 — Order is kept, not sorted

Input: ri!items
{
  "pie",
  "jam",
  "tea"
}
Output:
{
  "1. pie",
  "2. jam",
  "3. tea"
}

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