2/5

a!forEach(): combine two fields from each record

Easy

Each item is a map with a name and a city. Return one line per person in the form "Ann (Pune)".

Read a field out of a map with index(map, "field", default). The default is what comes back when the field is missing, and one record here is missing its city.

Input

  • ri!people — List of Map

ri! Rule Inputs

ri!peopleList of Map
{
  a!map(name: "Ann", city: "Pune"),
  a!map(name: "Bo", city: "Delhi")
}

Example 1 — Two people

Input: ri!people
{
  a!map(name: "Ann", city: "Pune"),
  a!map(name: "Bo", city: "Delhi")
}
Output:
{
  "Ann (Pune)",
  "Bo (Delhi)"
}

Example 2 — One person

Input: ri!people
{a!map(name: "Cy", city: "Mumbai")}
Output:
{"Cy (Mumbai)"}

Example 3 — A missing city becomes empty, not an error

Input: ri!people
{a!map(name: "Dee")}
Output:
{"Dee ()"}

Example 4 — Nobody

Input: ri!people
{}
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