Problems looping through results inside another loop

Hello I’ve already searched for this, but so far not had success.

I’ve used Make/Integromat before but would like to switch to N8N because of its ability to break down complex workflows.

Scenario: I have a loop with a nested loop inside. Outer loop is for pagination, e.g. getting results page by page, This works well. Inner loop is for looping over the content of each page (returned as a JSON). This does not work.

What I tried
a) Everything in one N8N workflow, one loop nested inside another. I learned that I need a Splitout-node to turn the JSON into structured results. But how do I close this loop again? If I do nothing, then the “if” and nodes afterwards from my outer loop will be executed several times as well.

b) tried to use a sub-workflow. I was able to call the subworkflow using “execute Workflow” in one workflow and “when executed by another workflow” in the other. But I don’t know how to process the data in the subworkflow. I see the data incoming in “Executions”, but I can only map them in the “editor” and that editor is empty.

I know how to program in Java and this is really simple in Java but complicated in N8N.

Would be great if someone could explain this to me like I am 5-years old.
Thank you so much
Bettina

Describe the problem/error/question

What is the error message (if any)?

None, but I don’t know how to map data in Subworkflow.

Please share your workflow

Main Workflow/workflow that calls subworkflow

{
“nodes”: [
{
“parameters”: {},
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
-580,
-605
],
“id”: “b0ca3eac-1dce-4501-9be8-31d9a2a7c89c”,
“name”: “When clicking ‘Test workflow’”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “bda39854-3a9b-4a9f-8c17-88cf0b27522a”,
“name”: “page”,
“value”: 1,
“type”: “number”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-360,
-605
],
“id”: “38213c20-77a5-4d9d-9bb8-1ea350e9259e”,
“name”: “Edit Fields”
},
{
“parameters”: {
“url”: “=testurl?page={{$json.page}}”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “=x-api-key”,
“value”: “reqres-free-v1”
}
]
},
“options”: {
“response”: {
“response”: {
“responseFormat”: “json”
}
}
}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
-140,
-605
],
“id”: “d3548736-2de1-4120-828a-4613eac499d4”,
“name”: “HTTP Request”
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “a6b7ac60-b6df-4d22-907a-9f629f74425d”,
“leftValue”: “={{ $json.page }}”,
“rightValue”: “={{ $json.total_pages }}”,
“operator”: {
“type”: “number”,
“operation”: “equals”
}
}
],
“combinator”: “and”
},
“options”: {}
},
“type”: “n8n-nodes-base.if”,
“typeVersion”: 2.2,
“position”: [
300,
-680
],
“id”: “9b9bc094-4392-4213-ad5e-dbdf4861b1b4”,
“name”: “If”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “facc6661-5679-4528-9730-89e21c3255b1”,
“name”: “page”,
“value”: “={{ $json.page +1 }}”,
“type”: “number”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
520,
-605
],
“id”: “b1c70f12-3685-4153-a378-7105b7fd7643”,
“name”: “Edit Fields1”
},
{
“parameters”: {
“workflowId”: {
“__rl”: true,
“value”: “3EPbk1KbMWyJWN4c”,
“mode”: “list”,
“cachedResultName”: “Subworkflow - Loop over items to write in Airtable”
},
“workflowInputs”: {
“mappingMode”: “defineBelow”,
“value”: {},
“matchingColumns”: ,
“schema”: ,
“attemptToConvertTypes”: false,
“convertFieldsToString”: true
},
“options”: {
“waitForSubWorkflow”: false
}
},
“type”: “n8n-nodes-base.executeWorkflow”,
“typeVersion”: 1.2,
“position”: [
80,
-680
],
“id”: “108df75f-265b-4085-8c62-2c2ca24b500b”,
“name”: “Execute Workflow1”
}
],
“connections”: {
“When clicking ‘Test workflow’”: {
“main”: [
[
{
“node”: “Edit Fields”,
“type”: “main”,
“index”: 0
}
]
]
},
“Edit Fields”: {
“main”: [
[
{
“node”: “HTTP Request”,
“type”: “main”,
“index”: 0
}
]
]
},
“HTTP Request”: {
“main”: [
[
{
“node”: “Execute Workflow1”,
“type”: “main”,
“index”: 0
}
]
]
},
“If”: {
“main”: [
,
[
{
“node”: “Edit Fields1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Edit Fields1”: {
“main”: [
[
{
“node”: “HTTP Request”,
“type”: “main”,
“index”: 0
}
]
]
},
“Execute Workflow1”: {
“main”: [
[
{
“node”: “If”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {
“HTTP Request”: [
{
“page”: 1,
“per_page”: 6,
“total”: 12,
“total_pages”: 2,
“data”: [
{
“id”: 1,
“email”: “[email protected]”,
“first_name”: “George”,
“last_name”: “Bluth”,
“avatar”: “https://reqres.in/img/faces/1-image.jpg
},
{
“id”: 2,
“email”: “[email protected]”,
“first_name”: “Janet”,
“last_name”: “Weaver”,
“avatar”: “https://reqres.in/img/faces/2-image.jpg
},
{
“id”: 3,
“email”: “[email protected]”,
“first_name”: “Emma”,
“last_name”: “Wong”,
“avatar”: “bild”
},
{
“id”: 4,
“email”: “[email protected]”,
“first_name”: “Eve”,
“last_name”: “Holt”,
“avatar”: “bild”
},
{
“id”: 5,
“email”: “[email protected]”,
“first_name”: “Charles”,
“last_name”: “Morris”,
“avatar”: “bild”
},
{
“id”: 6,
“email”: “[email protected]”,
“first_name”: “Tracey”,
“last_name”: “Ramos”,
“avatar”: “bild”
}
],
“support”: {
“url”: “Social Media Generator - AI Content Generator for LinkedIn, Twitter, Instagram | Content Caddy”,
“text”: “Tired of writing endless social media content? Let Content Caddy generate it for you.”
}
}
]
},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “3fe59674673aa1ee8c73f73cdc944b5eaa3b26185033a2c0922aeca6376ca1d3”
}
}

Subworkflow:

{
“nodes”: [
{
“parameters”: {
“operation”: “create”,
“base”: {
“__rl”: true,
“value”: “apppOTEjNcwk72IFl”,
“mode”: “list”,
“cachedResultName”: “Pages Data Entry”,
“cachedResultUrl”: “Airtable
},
“table”: {
“__rl”: true,
“value”: “tblh4bohOdOWd0bgU”,
“mode”: “list”,
“cachedResultName”: “Table 1”,
“cachedResultUrl”: “Airtable
},
“columns”: {
“mappingMode”: “defineBelow”,
“value”: {},
“matchingColumns”: ,
“schema”: [
{
“id”: “Name”,
“displayName”: “Name”,
“required”: false,
“defaultMatch”: false,
“canBeUsedToMatch”: true,
“display”: true,
“type”: “string”,
“readOnly”: false,
“removed”: false
},
{
“id”: “Notes”,
“displayName”: “Notes”,
“required”: false,
“defaultMatch”: false,
“canBeUsedToMatch”: true,
“display”: true,
“type”: “string”,
“readOnly”: false,
“removed”: false
},
{
“id”: “Assignee”,
“displayName”: “Assignee”,
“required”: false,
“defaultMatch”: false,
“canBeUsedToMatch”: true,
“display”: true,
“type”: “string”,
“readOnly”: false,
“removed”: false
},
{
“id”: “Status”,
“displayName”: “Status”,
“required”: false,
“defaultMatch”: false,
“canBeUsedToMatch”: true,
“display”: true,
“type”: “options”,
“options”: [
{
“name”: “Todo”,
“value”: “Todo”
},
{
“name”: “In progress”,
“value”: “In progress”
},
{
“name”: “Done”,
“value”: “Done”
}
],
“readOnly”: false,
“removed”: false
},
{
“id”: “Attachments”,
“displayName”: “Attachments”,
“required”: false,
“defaultMatch”: false,
“canBeUsedToMatch”: true,
“display”: true,
“type”: “array”,
“readOnly”: false,
“removed”: false
},
{
“id”: “Attachment Summary”,
“displayName”: “Attachment Summary”,
“required”: false,
“defaultMatch”: false,
“canBeUsedToMatch”: true,
“display”: true,
“type”: “string”,
“readOnly”: false,
“removed”: false
}
],
“attemptToConvertTypes”: false,
“convertFieldsToString”: false
},
“options”: {}
},
“type”: “n8n-nodes-base.airtable”,
“typeVersion”: 2.1,
“position”: [
-760,
-230
],
“id”: “91578f3f-9a03-4460-a380-c3c3a13a0773”,
“name”: “Write to Airtable”,
“credentials”: {
“airtableTokenApi”: {
“id”: “EOcONbBHLBwM8A7B”,
“name”: “Airtable Personal Access Token account”
}
}
},
{
“parameters”: {
“inputSource”: “passthrough”
},
“type”: “n8n-nodes-base.executeWorkflowTrigger”,
“typeVersion”: 1.1,
“position”: [
-980,
-230
],
“id”: “79292ce8-16d8-41b3-8477-6b2d8a2cfbdc”,
“name”: “When Executed by Another Workflow”
}
],
“connections”: {
“Write to Airtable”: {
“main”: [

]
},
“When Executed by Another Workflow”: {
“main”: [
[
{
“node”: “Write to Airtable”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“instanceId”: “3fe59674673aa1ee8c73f73cdc944b5eaa3b26185033a2c0922aeca6376ca1d3”
}
}

Share the output returned by the last node

[

{

“id”: “recgKdsYbB4cZ1CR9”,

“createdTime”: “2025-07-15T14:26:11.000Z”,

“fields”: {

“Attachment Summary”: {

“state”: “error”,

“errorType”: “emptyDependency”,

“value”: null,

“isStale”: false

}

}

}

]

Information on your n8n setup

  • n8n version:
    1.84.1

  • Database (default: SQLite):

sqlite

  • n8n EXECUTIONS_PROCESS setting (default: own, main):

Where do I find this? I am using self-hosted, but someone else installed it for me.

  • Running n8n via (Docker, npm, n8n cloud, desktop app):

  • npm

  • Operating system:

  • mac m1 14.5

N8n doesn’t support nested loops directly; they cause the child loop to be marked as “Done” prematurely and skip subsequent iterations. Several users report exactly this:

Only the first item in the inner loop is processed, and the rest go straight to “Done.”
For multiple levels, the results are unpredictable or the inner loops stop after the first iteration.

Divide the work into sub-workflows, each with a single loop, and call those sub-workflows from the parent loop:

Parent workflow:

  • Loop over verbs.
  • Inside, call a sub-workflow with adjectives and nouns.

Sub-workflow:

  • Receives the current verb as a parameter.
  • Loop over adjectives.
    • Inside, another loop over nouns.
    • Generates the final combination and returns the results.

This approach ensures that each level executes completely without interference.

I dont get the problem. Can you provide a bit more details

Thank you everyone for your response.

Even though I understand the architecture with a sub workflow in principle. I still don’t understand why the sub workflow has no data and the nodes afterwards have red warnings.

Tried a bunch of things that ChatGPT suggested but it didn’t work either.

The data is empty:

But in the executions tab I can see it gets into the sub workflow but is not mapped properly (in the url of the screenshot you can see the executions url)

Bit exhausted by this, what else could I try?

Apparently calling the subworkflow seems to be working now.

  • Code node after Http Request to process JSON
  • Execute Workflow node with settings “run for each item”

I’d like to thank you for your help!



There is still an error in my main workflow, but at least that is working now.

thank you!!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.