⚒️ Fetch hierarchical data records from Airtable with multi-level relationships

245 views · ⚒️ Engineering

Description

Airtable Hierarchical Record Fetcher

Description

This n8n workflow retrieves an Airtable record along with its related child records in a hierarchical structure. It can fetch up to 3 levels of linked records and assembles them into a comprehensive JSON object, making it ideal for complex data relationships and nested record structures.

Features

Input Parameters

The workflow accepts a JSON array with the following structure:

[
  {
    "base_id": "appN8nPMGoLNuzUbY",
    "table_id": "tblLVOwpYIe0fGQ52", 
    "record_id": "reczMh1Pp5l94HdYf",
    "level_3": [
      "fldRaFra1rLta66cD",
      "fld3FxCaYk8AVaEHt"
    ],
    "to_html": true
  }
]

Parameter Details

ParameterTypeRequiredDescription
base_idstringYesAirtable base identifier
table_idstringYesAirtable table identifier for the main record
record_idstringYesAirtable record identifier to fetch
level_3arrayNoArray of field IDs from level 2 records for which to fetch level 3 children
to_htmlbooleanNoConvert rich text fields from pseudo-markdown to HTML (default: false). This requires marked npm package.

Output Structure

The workflow returns a hierarchical JSON object with the following structure:

{
   "id": "recXXXXXXX",
   "field_1": ...,
   "field_2": ...,
   "level2_child": [
      {
         "id": "recXXXXXXX",
         "field_a": ...,
         "field_b": ...,
         "level3_child": [
            {
               "id": "recXXXXXXX",
               "field_y": ...,
               "field_z": ...,
            },
            ...
         ]
      },
      ...
   ]
}

🔗 Nodes Used

Airtable, HTTP Request, Execute Workflow Trigger, Filter

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup