collected_records_collect_referenced_records
Use this action to collect the records that the records of an earlier collection relate to.
Read the live config shape of each action type from GET /v1/automation/meta/action before you build on it.
In the automation editor, this action is Get related records in the Record collections family. Its group is action, and it works with every trigger but needs an earlier action that creates the record collection it starts from.
Send it in the actions array of Create an automation or Update an automation. An update replaces the whole array, so include the other actions.
Example
An earlier action collected solar installations from database app 87. This action collects the customers that those installations point to:
{
"type": "collected_records_collect_referenced_records",
"config": {
"record_collection": { "kind": "variable", "source": "action", "action_type": "record_collection", "app_id": 87 },
"ref_collection_defs": [
{
"direction": "outgoing",
"match_type": "all",
"app_id": 91,
"via_field_ids": [55012]
}
]
}
}
Config
| Property | Type | Description | Example value |
|---|---|---|---|
record_collection | reference | Required. The collection to start from, created by an earlier action. The schema lets you save without it, but validation then reports action_invalid. | { "kind": "variable", "source": "action", "action_type": "record_collection", "app_id": 87 } |
ref_collection_defs | array of reference steps | The steps that Tape follows from the records in the collection. Empty when left out, and then the action collects nothing. | [{ "direction": "outgoing", "match_type": "all", "app_id": 91 }] |
Each step has the same keys as in collect_referenced_records:
direction(required):outgoing,incomingorboth.match_type(required):allkeeps every related record,filteredkeeps only the records that matchmatch_condition.app_id: the related database app. Validation reportsaction_app_missingwithout it.via_field_ids: the relation fields to follow.match_condition: a filter group for thefilteredmode. An empty AND group when left out, read back asnull.id: stable ID of the step. Tape creates one when you leave it out and returns it on read.
With more than one step, Tape follows them as a chain. Each step starts from the records that the step before it found.
To find app_id and the relation field IDs for via_field_ids, see App and field IDs.
Use the collection in later actions
Each step creates a record_collection for its app_id. A later action references the customers from the example with this object:
{ "kind": "variable", "source": "action", "action_type": "record_collection", "app_id": 91 }
- Tape resolves the reference to the nearest earlier action that creates a collection for the same
app_id. - Use it in
filter_record_collection,sort_record_collection,clear_record_collection, thecollected_records_*actions and theiterableof afor_loop. - See Record collections for the pattern.
General behavior
- This action uses one collection and creates another. It starts from
record_collectionand fills a record collection for theapp_idof each step. record_collectionhas no default. Without it, Tape saves the action, and validation reportsaction_invalid.- A
record_collectionwithout a matching earlier action fails validation withaction_variable_missing. directionandmatch_typehave no default. Send both on every step, as lower-case tokens.- Neither the save nor
validatereports a step withoutdirectionormatch_type. The step then reads back without both keys. - Each step's
app_idmust relate to the database app before it. Otherwise validation reportsaction_app_invalid. - For each step, the run log shows how many records Tape collected.
Requirements
- To add or change this action through the API, your token needs the
automations:editcapability. See Capabilities. - You must administer the workspace that the automation's database app belongs to.
- An earlier action in the automation must create the collection in
record_collection, for examplecollect_app_records.