IF node when iterate over multiple items

I tried to figured out, how n8n handle the if node when iterate over multiple items?

I’ve set the date_in_set_node variable in Set node, in function node I created multiple items (30) with the same value stored in item_date

Then i need to check for each iterations, if value of the current iteration of item_date is equal to the date_in_set_node value using if node

I would like to understand why I only get 1 true iteration in First case exemple, should I not get 30 true iterations ? The if node seems to stop iterations.

In Second case , I force the loop with a splitInBatches nodes and the result is 30 items true.

In Third case , I use same function as other exemple, except that I push in newItems object the value of date_in_set_node, in key item_set_date in Function1 node.
Then I compare if both values in the following if node are equal ( item_set_date == item_date)
So I also get as results 30 items true.

Is First case a normal behaviour ? A bug ? A misunderstanding ? Something else ?

Thanks for your help !

My workflow

Information on my n8n setup

  • n8n version: 0.187.1
  • MySQL Database
  • Running n8n via desktop app

Welcome to the community @fmarrot :tada:

In your First case IF node you are using an expression of {{$node["Set"].json["date_in_set_node"]}}. The node does however receive 30 items. Now for the first item this IF node receives, it would look up the first item of on the Set node and read the date_in_set_node value for this item. This is working fine. However, for the second item it receives it would look up the second item from the Set node which does not exist. This is why 29 items are sent to the false output here.

So instead of of {{ $node["Set"].json["date_in_set_node"] }} you would want to use something like {{ $items("Set")[0].json["date_in_set_node"] }} to always read the first (and only) item from your Set node:

Afterwards, all items should go to the true output:

Hope this helps!


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