Wrong item is retrieved

Hello,

Describe the issue/error/question

I am making an API call. 6 items are returned. I am using an IF node to filter these items.
Item 1 and 6 pass this node as TRUE, but when I try get from these 2 items a previous JSON field (with {{ $node["<node>"].json["_id"]}}), the ID of item 1 and 2 are returned, not 1 and 6.

My question is : how can I get this ID field for the right item ? I’ve tried thnigs such as {{ $item.$node["<node>"].json["_id"]}} but nothing works, n8n keep returning me IDs in the original order.

Please share the workflow

The workflow is quite ““sensitive”” so I would not prefer sharing it here. I can still send it by private message or so if my question is unclear.

Share the output returned by the last node

Here is a quick plan of observed behaviour/expected behaviour : https://i.imgur.com/ohQofbh.png

Information on your n8n setup

  • n8n version: 0.212.1
  • Database you’re using : PostgreSQL
  • Running n8n via : Docker

Hey @GGZ78,

Are you able to create a simplified version of the workflow that produces the same issue? I would maybe start by updating n8n and using the newer syntax which will use paired items and may have better results for you.

What is the last version ?
The version displayed aboved is the version I get when I put image: n8nio/n8n in my docker-compose.yml file.

Here is my workflow :

Node GetEchangeClient returns 6 items : only the 1st and the 6th will pass the IF node as TRUE.
But when I try to get {{ $node["GetEchangeClient"].json["_id"] }} in Relance #2 TheHive node, ID of 1st and 2nd item are returned.

Hey @GGZ78,

The latest version is 0.218.0 so you would need to pull the image again. I would start with the update and syntax change to see if it helps.

What tends to happen is we would loop the index of the node so for the first item we would use index 0 and on the second we would use index 1 normally if you are just using $json with the output of the previous node there isn’t an issue but when going back a few nodes you can start to see issues.

The idea with Paired Items is we would link the data together in a smarter way which should help reduce a lot of these issues.

You could also use a split in batches to have more control and after getting the ID add in the split in batches node to loop over the clients one at a time then you can use the ID from the split in batches node and it should be all good.

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