Unable to access data from previous nodes

Unable to access data from previous nodes

(Posting first time so might make some errors in asking question. )

The issue seems that i cant access data even though it is present in the earlier nodes. I tried a bunch of stuff but nothing worked. originally i had a for loop node setup to go through many emails but now i am trying to fix it with atleast one then i can copy paste it 4 four times. Below are some screenshots that might help. The data can be accessed by $json notation by the immediately next node but not by a later node using $(‘Edit Fields’).item.json.

Information on your n8n setup

  • n8n version: 1.42.1
  • Database: SQLite
  • n8n EXECUTIONS_PROCESS setting: own
  • Running n8n via: Docker
  • Operating system: Linux Ubuntu

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:

hello @Ahmad_Rajput

You can’t access the item property of the node, that has a different amount of outputted items.

In your case use the below syntax:

$('Edit Fields').last().json
2 Likes

Thank you so much! Been stuck on it hours.

Quick question: why does .last() works? I see that for other case my loop works first time okay for a node data before loop but not after the first loop. Although I solved this issue using your .last() method but i am still curious. Here is the Screenshots:


Because last() method will access the last item of the node no matter how many items it has and it doesn’t care of what is the current $itemIndex.

However, item property will work only if that item is linked to the previous nodes (basically, has the same $itemIndex). Usually, it does but there are some nodes that will change that behavior. The Loop node is one of those kind of nodes.

1 Like

Thank you!

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