Skip to main content
1/5

a!update(): replace one item by position

Easy

Return the list with the item at ri!position replaced by ri!value.

Positions count from 1, and every other item keeps its place.

Inputs

  • ri!items: List of Text
  • ri!position: Integer
  • ri!value: Text

ri! Rule Inputs

ri!itemsList of Text
{
  "a",
  "b",
  "c"
}
ri!positionInteger
2
ri!valueText
"X"

Example 1: The middle item

Input: ri!items
{
  "a",
  "b",
  "c"
}
Input: ri!position
2
Input: ri!value
"X"
Expected output:
{
  "a",
  "X",
  "c"
}

Example 2: The first item

Input: ri!items
{
  "a",
  "b"
}
Input: ri!position
1
Input: ri!value
"X"
Expected output:
{
  "X",
  "b"
}

Example 3: The last item

Input: ri!items
{
  "a",
  "b"
}
Input: ri!position
2
Input: ri!value
"Z"
Expected output:
{
  "a",
  "Z"
}

Example 4: A single item list

Input: ri!items
{"only"}
Input: ri!position
1
Input: ri!value
"new"
Expected output:
{"new"}

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