record_tasks()

Get the open tasks linked to a record, as a list you can loop over. Backs the Get Record Tasks automation step.

Syntax

record_tasks(table, recordId)

Parameters

Name Type Required Description
table string yes Table name or id of the record the tasks are attached to.
recordId int yes The record's primary key.

Returns

A list (array) of the record's open tasks (completed tasks are excluded). Each item is a flat dictionary — not a table-record shape — with these keys:

id, title, details, status, due_date, due_time, created_at, updated_at, completed_at, record_id, table_id, space_id, assignee_id, assignee_email, assignee_name, creator_id, creator_email, creator_name, completed_by_id, completed_by_email, completed_by_name.

These are the same fields the On Task Completed trigger exposes as {{task.*}}.

Example

$tasks = record_tasks("leads", $record["_meta"]["id"]);
sys_log($record["name"] . " has " . count($tasks) . " open task(s)");
foreach ( $tasks as $task ) {
    sys_log(" - " . $task["title"] . " (due " . $task["due_date"] . ") → " . $task["assignee_email"]);
}

Example output

[
    ["id" => 12, "title" => "Follow up", "status" => "open", "due_date" => "2026-08-01", "assignee_email" => "jane@example.com", ...],
    ["id" => 15, "title" => "Send quote", "status" => "open", "due_date" => "2026-08-03", "assignee_email" => "sam@example.com", ...]
]

Notes

  • Only open tasks are returned. There is no option to include completed tasks.
  • Items are plain dictionaries, so read fields by their flat key ($task["title"], or {{task.title}} in a For Each loop) — not the {{record.<fieldId>}} syntax used for table records.
  • Returns [] when the record has no open tasks.

See also: records_related()