Node Drive+Sheets+IF

Hello! me again, sorry! hahah

I have a question about the IF Nodes, I have a situation where I am comparing 2 pieces of information if they are the same or not, for example I share the Drive + Sheets Node and then the IF, (in sequence) in the Drive I have 1 file called (Sheets) “148” and in Google Sheets I have information with IDs, which are, for example, 101, 103, and 148 (in this ID I have 4 the same but with different information about the row), if in the IF node I am going to look for the " IDs" always in the Drive one grabs me the first one and the other 3, 148 throws them to the false one, if I put the “148” in text format in the IF comparison without going to look for the node, it puts the 4 to true and none to false, the issue is that I have many IDs, and they are constantly changing, which is almost impossible to put them in text format, is there a way to solve that? What I realize about the Drive node is that it always reads me the last file, is there a query to read the full number of files there are?

As always, thank you very much for the help everyone!

Pics:


Hey @Internalit_Automatio,

It looks like the problem here is going to be how we loop over items, So what we do internally is loop the node once for each input input item so if your input to a node has 4 items we will run 4 times. When you use $node[name] we try to be clever so the first run will use the first item and the second will see if there is a second item so if you had…

$node[name] outputting 2 items so say…

[
  { 'id': 1 },
  { 'id': 2 },
]

Then you had the next node which outputted 4 items…

[
  { 'text': 'foo' },
  { 'text': 'bar' },
  { 'text': 'n8n' },
  { 'text': 'rocks' },
]

Then next up we have an if node, This if node will run 4 times as we have 4 inputs so when you use $node[name] this is what you would see…

run 1
$node[name].id = 1
$json[text] = foo

run 2
$node[name].id = 2
$json[text] = bar

run 3
$node[name].id = undefined
$json[text] = n8n

run 4
$node[name].id = undefined
$json[text] = rocks

… That roughly covers what is happening and hopefully it makes some kind of sense… To get around this you could use a split in batches node after $node[name] which would run once for each item so you could then do your if check against the split in batches node then at the end of your check for that one item you would loop back to the split in batches node so it can pick up the next item.

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