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"
}Expected output:
{
"Ann",
"Bo",
"Cy (latest)"
}Example 2: A single name is also the last one
Input: ri!names
{"Ann"}Expected output:
{"Ann (latest)"}Example 3: Two names
Input: ri!names
{
"Ann",
"Bo"
}Expected output:
{
"Ann",
"Bo (latest)"
}Example 4: Nothing to mark
Input: ri!names
{}Expected output:
{}Appian Expression Tips
- • Use
ri!variableNamefor 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