4/5

a!forEach(): mark the most recent entry

Medium

Return every name unchanged, except the last one, which gets " (latest)" appended.

{"Ann", "Bo"} becomes {"Ann", "Bo (latest)"}.

Do not count the items to work out which one is last. fv!isLast is true on the final pass and false everywhere else.

Input

  • ri!names — List of Text

ri! Rule Inputs

ri!namesList of Text
{
  "Ann",
  "Bo",
  "Cy"
}

Example 1 — Three names

Input: ri!names
{
  "Ann",
  "Bo",
  "Cy"
}
Output:
{
  "Ann",
  "Bo",
  "Cy (latest)"
}

Example 2 — A single name is also the last one

Input: ri!names
{"Ann"}
Output:
{"Ann (latest)"}

Example 3 — Two names

Input: ri!names
{
  "Ann",
  "Bo"
}
Output:
{
  "Ann",
  "Bo (latest)"
}

Example 4 — Nothing to mark

Input: ri!names
{}
Output:
{}

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