How to Use Subworkflow output in Main Workflow

I have a workflow Main and sub workflow
subworkflow generate an output
{


"customernumber": "1234567"
}

in the main workflow how do I used that?

I tried


{{ $json.output.customernumber }}
{{ $json.query.customernumber }}

but it doesnt work

the data is being pulled from the subworkflow though just not sure how to add it on expression

Information on your n8n setup

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

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

You have to call the subworkflow, from the main workflow, using “Execute Sub-workflow” node.

The subworkflow will return the output from its last executed node, automatically.

Alternatively you can enable the option “Respond to webhook” on the trigger of the workflow and add a “Respond to webhook” node to return the data you want, in any part of the workflow.

See documentation here

Hello, I hope you are doing well. I understand that you want to capture the output of the sub-workflow of a sub-agent that performs an operation and returns the value: “customernumber”: “1234567”. In my opinion, in that sub-workflow you must capture that data with a tool (database, etc.). It could be the same one that the main flow is using, so you can transfer that data. I hope this helps. Best regards.

the subflow output already send the data to the main workflow, the issue is using it, what syntax or expression i should used?

Hi, just use $json in the next node after the “Execute Subworkflow” node to access the result. Or use $(‘Name of the Execute Subworkflow node’) to access the data.