index(): read a field out of a record
Easy
Return the ri!field value from the record. When the record has no such field, return "unknown".
The second argument is the field name as text.
Inputs
ri!person— Mapri!field— Text
ri! Rule Inputs
ri!personMapa!map(name: "Ann", city: "Pune")
ri!fieldText"name"
Example 1 — A field that is there
Input: ri!person
a!map(name: "Ann", city: "Pune")
Input: ri!field
"name"
Output:
"Ann"
Example 2 — A different field
Input: ri!person
a!map(name: "Ann", city: "Pune")
Input: ri!field
"city"
Output:
"Pune"
Example 3 — A field the record does not have
Input: ri!person
a!map(name: "Ann")
Input: ri!field
"city"
Output:
"unknown"
Example 4 — A record with nothing in it
Input: ri!person
a!map()
Input: ri!field
"name"
Output:
"unknown"
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