Getting the correct data from before an IF node

I’m having trouble with workflows where I need to check a condition, then grab info from nodes prior to the IF node to do an operation.

Let’s say I have 3 items from a search node. I want to check each item for a specific condition which I do with the IF node. If true, I want to do something to the item but I need some data from a node not immediately preceding the IF node. (In the example below, I need some info from the Bubble node).

What happens is: Items 1 and 2 go to the false branch, then on item 3 when I try to get the corresponding item from the Bubble node, it actually gets item #1. How do I get the correct item from before that IF node?

The workaround for me has been using SplitInBatches, which forces the data to be one item at all times so I can always get the correct one if the IF branch resolves to true. However, I feel like I’m missing something obvious here.

Working example using SplitInBatches:

Hey @Giovanni_Segar, your problem should be solved by the paired item functionality we’re currently working on (essentially giving you an easy way to get the connected items from previous nodes).

For now, the easiest approach would be to use a Set node before your IF node, pulling in all the data you might need after the IF node.

1 Like

Ok thanks for your help!

1 Like

Hello @MutedJam !

Just a quick bump because I can’t seem to find the feature you are talking about “paired items” on n8n right now, is it still in active development ?

Were you able to get this solved?

Because I am facing this same issue now.

I Set the value before the If node. But I am unable to get the date into my Bubble node after If.

Please use the $("nodeName").item syntax. It will then use the paired item functionality and so automatically resolve to the correct item.

@jan To be clear, if I have 3 items going to an IF node and only the 3rd one gets through, using that syntax will match the 3rd output from whatever node I reference, even if it’s several nodes behind the IF? That’s great :smiley:

Yes exactly. That is what the paired item functionality enables and ensures to be correct.

1 Like

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