Skip to main content
26/31

Group Tasks by Status for a Summary Grid

Medium

A task report shows one row per status. You are given the tasks as a list of maps, each with id, status and assignee.


Return one map per status, in the order each status first appears in the list:

  • status: the status text
  • count: how many tasks have it
  • taskIds: the ids of those tasks, in list order

An empty task list returns an empty list.


Why it comes up: Appian has no group-by for a local list, so this is how a summary is built when the data is already in memory and a second query is not worth it.

ri! Rule Inputs

ri!tasksList of Map
{
  a!map(id: 1, status: "Open", assignee: "ana"),
  a!map(id: 2, status: "Done", assignee: "raj"),
  a!map(id: 3, status: "Open", assignee: "li"),
  a!map(id: 4, status: "Blocked", assignee: "ana"),
  a!map(id: 5, status: "Done", assignee: "ana")
}

Example 1: Three statuses

Input: ri!tasks
{
  a!map(id: 1, status: "Open", assignee: "ana"),
  a!map(id: 2, status: "Done", assignee: "raj"),
  a!map(id: 3, status: "Open", assignee: "li"),
  a!map(id: 4, status: "Blocked", assignee: "ana"),
  a!map(id: 5, status: "Done", assignee: "ana")
}
Expected output:
{
  a!map(status: "Open", count: 2, taskIds: {1, 3}),
  a!map(status: "Done", count: 2, taskIds: {2, 5}),
  a!map(status: "Blocked", count: 1, taskIds: {4})
}

Example 2: One status

Input: ri!tasks
{
  a!map(id: 10, status: "Open", assignee: "ana"),
  a!map(id: 11, status: "Open", assignee: "raj"),
  a!map(id: 12, status: "Open", assignee: "li")
}
Expected output:
{a!map(status: "Open", count: 3, taskIds: {10, 11, 12})}

Example 3: Order of first appearance

Input: ri!tasks
{
  a!map(id: 7, status: "In Review", assignee: "li"),
  a!map(id: 8, status: "Open", assignee: "li"),
  a!map(id: 9, status: "In Review", assignee: "raj"),
  a!map(id: 3, status: "Closed", assignee: "ana")
}
Expected output:
{
  a!map(status: "In Review", count: 2, taskIds: {7, 9}),
  a!map(status: "Open", count: 1, taskIds: {8}),
  a!map(status: "Closed", count: 1, taskIds: {3})
}

Example 4: No tasks

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