Using values from previous nodes - cant get data for expression

Describe the problem/error/question

Hi all.

I have a node that i am having issues with using values from previous nodes.
For example.
image

Now these values have no issues working, and i am pulling them from 1 node back.
image

When i change the input dropdown to a different node or use the edit expression option to grab previous nodes, i have no issue seeing the values i want to pull in however if i try to use one it gives me an error that i cant get data for expression

Is there a special way to pull in multiple nodes?


ExpressionError: Can’t get data for expression
at createExpressionError (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/WorkflowDataProxy.js:465:20)
at getPairedItem (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/WorkflowDataProxy.js:517:27)
at pairedItemMethod (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/WorkflowDataProxy.js:734:40)
at Object.get (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/WorkflowDataProxy.js:737:40)
at Proxy.eval (eval at getFunction (/usr/local/lib/node_modules/n8n/node_modules/@n8n/tournament/dist/index.js:24:22), :6:57)
at Tournament.execute (/usr/local/lib/node_modules/n8n/node_modules/@n8n/tournament/dist/index.js:33:19)
at evaluateExpression (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/ExpressionEvaluatorProxy.js:110:16)
at Expression.renderExpression (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Expression.js:217:70)
at Expression.resolveSimpleParameterValue (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Expression.js:195:34)
at resolveParameterValue (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Expression.js:276:25)

Information on your n8n setup

  • n8n version:
    Docker, Onprem, Community, latest build

Thanks for all the help.

Welcome to the community @Petero!

The issue is probably that you did not provide the pairedItem information in the Code-Node. How to do provide it, is documented here:

Hey Mate.

Thanks for the welcome.

So just to confirm.

My Node GetLastMexWOID has a output that looks like this.

image

Now the next node in line “Mobaro2Mex” has the input set as my last node being GetLastMexWOID

And the mapped values pull in fine

Now if i change the input on my “Mobaro2Mex” node to node “Item Lists” which is 3 nodes back, i can see all the values on the input screen

So now i will add a new parameter to the body of the node called “WorkOrderDescription” and add the value linked to “name” in the “Items Lists” Node. You can see the data is pulling in.

Now from what i can tell, the issues start to arise when there are more then one array returned which i split out using the “Items List Node”.

So when i am in my current final node " Mobaro2Mex" having set the value
{{ $(‘Item Lists’).item.json.name }} for the Work Order Description

Where the input “Item Lists” now shows i have 2 items and using the schema view to link the fields

And Table View in input Looking like this

image

i now get an error in the node.

image

I am trying to run this api call as many times as needed with the values of each row and the api will reply back with all the remaining required fields that i then need to post back in on another step ( haven’t got to that part)

Now, given all the values are mapping correctly in the input views do i still need to do this item linking thing and if so do i need to do that javascript in the values of this node?

Cheers

Hi @Petero, did you add the paired/linked item logic to your code as suggested by Jan above?

If not you could alternatively consider using legacy expressions like {{ $node['Item Lists'].json.name }} which do not rely on these properties to be available, but you would need to make sure that neither the order nor number of your items change in this case.

1 Like

good morning @Petero
How did you solve this problem? It’s happening to me too

I’ve had the same problem (I think) on a very simple flow.

In the Input area (5 nodes back) I can see the data and it’s correct, but when I drag-and-drop, I get the Can't get data: error from:
{{ $('Add Form Trigger').item.json.Text_to_Add }}

But everything works when I use the legacy:
{{ $node['Add Form Trigger'].json.Text_to_Add }}

Is this a known problem?

2 Likes

@RichardC, it is a known “problem” when the required pairedItem information is not provided in a code-node. Does your Workflow use a Code-Node and if that is the case, did you provide the pairedItem information?

If it does not contain a Code-Node please share your workflow that we can see what is going on.

I believe the problem was me. When using an IF node, dragging a form field from several nodes back didn’t work, but using the legacy version did, but only because the Condition I was dragging into was set to Fixed. The drag and drop works when the Condition is set to Expression. My mistake.

FWIW (if you would like the first impression of someone new to n8n) where the UI shows Fixed | Expression the selected item has a white background and the unselected item is gray. To me, that’s nonintuitive. I know fx is also shown below when Expression is selected, but if you would like to make that choice as clear as possible, perhaps a simple on/off toggle button labeled Expression would be worth considering.

Cheers, Richard

Great to hear that you found a solution. But sadly, I do not understand what was going on exactly. Every time a field gets dragged on a parameter it should get automatically changed to “Expression” as only like that, it can work and so would make sense. I also just tried in a small local example workflow. For me, it always sets the Parameter to “Expression” automatically.

I believe I used drag and drop in one node, and then created another version of that node and used copy-paste which doesn’t toggle the expression mode. Thanks for your thoughtful replies.

Thanks! Didn’t know about the legacy syntax. It works for me when the new version doesn’t