Describe the problem/error/question
How can I merge two objects one by one and get all merged objects in a list?
I want to merge two objects into one object, one by one from a list of objects. But whatever I do I end up with a cartesian product, or only one item being merged with all items in the list.
I am trying to make a list of work items from Azure Devops and list their children. Problem here is that the main query (the work items) have a sub-list with relations where some of them are the children I want to show but the children have no relation to their parent, I really need to merge them on a one-by-one basis.
The API is what it is and this what I have to do:
- Query work items with filters - responds with an array of
{ id: 111, url: ‘http…’ } - Query next API with the ID one at a time to get a new response that includes related items, who may be of type Child - responds with
{ id: 111, fields:{xyz}, relations: [ { id: 152, url: ‘http…’ }, { id: 152, url: ‘http…’ } ] } - Query Children data - responds with a child similar to the the work item
{ id: 152, fields:{xyz}, relations: [ { id: 152, url: ‘http…’ }, { id: 152, url: ‘http…’ } ] }
There may be n children, but the child response have no relation ID pointing to the parent. I need to take the parent and for each children merge the parent data I need with that child data I need.
I’ve really tried everything I can think of and either I don’t understand the Loop nor the Merge or there is something not working as expected.
I ended with a Loop over items to do this for each work item, fetch the children and decorate each child with parent data with help of a Merge. But what I experience is that even though the flow is what I believe is a one-by-one loop, the merge sees ALL 34 mothers and their children and then combine them.
The mother list is always a list if items.
The child list can be n number if items, i.e. 0 or 7.
I always want the mother out, even if children is zero.
Or 7 mothers with one children in each of them.
Here are some examples I want to combine:
# MOTHER
{
"motherId": 12406,
"motherWorkItemType": "Bug",
"motherArea": "Bugs and Repair",
"motherTitle": "Bug for exception (MassTransit.UnhandledEventException) in production",
"motherState": "Code Review",
"motherAssignedTo": "Pallavi Sinha",
"motherEmail": "[email protected]",
"motherChangeDate": "2025-11-27T16:19:41.317Z"
}
# CHILDREN
{
"childId": 12454,
"childWorkItemType": "Work Time",
"childTitle": "Time on Bug for exception (MassTransit.UnhandledEventException)",
"childState": "Closed",
"childAssignedTo": "Pallavi Sinha",
"childEmail": "[email protected]",
"childTimeOnTask": 1
},
{
"childId": 12421,
"childWorkItemType": "Work Time",
"childTitle": "Work time on bug",
"childState": "Closed",
"childAssignedTo": "Roger Morrison",
"childEmail": "[email protected]",
"childTimeOnTask": 2
},
# EXPECTED OUTPUT
{
"motherId": 12406,
"motherWorkItemType": "Bug",
"motherArea": "Bugs and Repair",
"motherTitle": "Bug for exception (MassTransit.UnhandledEventException) in production",
"motherState": "Code Review",
"motherAssignedTo": "Pallavi Sinha",
"motherEmail": "[email protected]",
"motherChangeDate": "2025-11-27T16:19:41.317Z",
"childId": 12454,
"childWorkItemType": "Work Time",
"childTitle": "Time on Bug for exception (MassTransit.UnhandledEventException)",
"childState": "Closed",
"childAssignedTo": "Pallavi Sinha",
"childEmail": "[email protected]",
"childTimeOnTask": 1
},
{
"motherId": 12406,
"motherWorkItemType": "Bug",
"motherArea": "Bugs and Repair",
"motherTitle": "Bug for exception (MassTransit.UnhandledEventException) in production",
"motherState": "Code Review",
"motherAssignedTo": "Pallavi Sinha",
"motherEmail": "[email protected]",
"motherChangeDate": "2025-11-27T16:19:41.317Z",
"childId": 12421,
"childWorkItemType": "Work Time",
"childTitle": "Work time on bug",
"childState": "Closed",
"childAssignedTo": "Roger Morrison",
"childEmail": "[email protected]",
"childTimeOnTask": 2
}
What is the error message (if any)?
Whatever I do it seems the Merge sees all items in the Loop and do all sorts of combinations. In my test there are 36 items with 36 children. I want 36 merged items out but eventually get 36 x 36 = 1156 items, or 36 items with different mothers but the same child (first item) in all of the mothers.
Please share your workflow
Share the output returned by the last node
Information on your n8n setup
- n8n version: 1.117.3
- Database (default: SQLite): Postgres
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app): Kubernetes
- Operating system:
