Variable values are resolving as undefined from subworkflows. When using the $vars.MyVariableName syntax, the value comes through when I run the workflow directly. But if I call the workflow from another workflow, the value is missing.
I get an undefined value coming back from my $vars.MyVariableName reference.
{ "nodes": [ { "parameters": { "inputSource": "passthrough" }, "type": "n8n-nodes-base.executeWorkflowTrigger", "typeVersion": 1.1, "position": [ 0, 0 ], "id": "2b88243e-6e3a-4e0b-912a-a6a11ce2e477", "name": "When Executed by Another Workflow" }, { "parameters": { "assignments": { "assignments": [ { "id": "a7e9ac8c-7904-4c53-ae65-1a67a43920f2", "name": "MyValue", "value": "={{ $vars.MyVariableValue }}", "type": "string" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 416, 0 ], "id": "ba1ae72e-a842-4404-9ea8-694110e72e0c", "name": "Edit Fields" }, { "parameters": { "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.myNewField = "TEST " + $vars.MyVariableValue;\n}\n\nreturn $input.all();" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 208, 0 ], "id": "5e29c928-076d-4ba0-bf9c-fdb95dd0f7b5", "name": "Code in JavaScript" } ], "connections": { "When Executed by Another Workflow": { "main": [ [ { "node": "Code in JavaScript", "type": "main", "index": 0 } ] ] }, "Code in JavaScript": { "main": [ [ { "node": "Edit Fields", "type": "main", "index": 0 } ] ] } }, "pinData": { "When Executed by Another Workflow": [ {} ] }, "meta": { "instanceId": "f35a2873842c236fe446a77d860bb0c2fdae7f09a67dd0b280ad5680de01fafc" } }
Output from the last 2 nodes where I try to reference the variable.
Generated at: 2025-11-27T11:31:44.194Z}