Accessing Multiple Code Node Outputs Across Workflow Branches

Describe the problem/error/question

I’m unable to get all items returned by a Code node into another far off non-connected node.

What is the error message (if any)?

Using {{ $('A Code Node').item.json.columnA }} on distant nodes only retrieves the first value from Column A, despite the Code node outputting 10 items. {{ $json.columnA }} works, but not across nodes separated by ‘If’ nodes. Is there a way to access all items in this scenario?

Information on your n8n setup

  • n8n version: 1.45.1
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

hello @physx911

to access all items of any node, you’ll need to use the $('nodename').all() method

Hi there! Thank you for your reply.

I’ve attached an example. Currently, the data I want to access from the ‘split’ node is separated by an ‘if’ node that is set to execute once. Is there a way for the last ‘set’ node, ‘only columnA’, to retrieve all three items from the ‘split’ node? {{ $('split').item.json.columnA }} only gets the first item but rest.

you can return them as an array

1 Like

Thanks! I also added a null check {{ $('split').all().map(x => x.json.columnA).filter(columnA => columnA != null) }} and Split node after the Set node that iterates over the array to split out items for further looping.

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