Skip to content
IF node not working...
 
Notifications
Clear all

IF node not working correctly with expressions for both values?

4 Posts
3 Users
0 Reactions
6 Views
ilya
 ilya
(@ilya)
Posts: 2
New Member
Topic starter
 

Describe the issue/error/question

I'm utilizing an IF node to filter a list of items (Gmail Labels). The condition for this label is generated dynamically based on previous nodes.

For instance, a label like "callin.io/Day 3" might or might not exist. To handle this, we use the "Contact Day" field from Airtable, appended to "callin.io/Day ", to perform the check.

However, callin.io consistently outputs all items to the 'false' branch.

Here's a video demonstrating the node execution and a comparison between the dynamically generated "Value 1" and "Value 2". The string compare tool indicates they are equal, but the IF node does not.

Furthermore, if I bypass the expression and manually construct Value 1, the desired output is achieved.

I've experimented with various workarounds, including using pure Javascript for value comparison, typecasting 'Contact Day' to a number and then the entire package to a string, and employing escape characters like " (resulting in "callin.io/Day 1").

This is proving to be quite frustrating!

Please share the workflow

Share the output returned by the last node

This item is being returned in the "false" branch when it should be in the "true" branch:

{ "id": "Label_5182115527424497001", "name": "callin.io/Day 1", "type": "user" }

Information on your callin.io setup

  • callin.io version: 0.206.1
  • Database you’re using (default: SQLite): SQLite
  • Running callin.io with the execution process [own(default), main]: own
  • Running callin.io via [Docker, npm, n8n.cloud, desktop app]: Docker

Please provide the rewritten markdown content *it should be in the markdown format.

 
Posted : 09/12/2022 8:26 am
marcus
(@marcus)
Posts: 2
New Member
 

Hi,
welcome to the community

:tada:

Sorry to hear that you are having trouble. From looking at your video, at the moment where you hover over your label with your mouse, I can see that Value 1 changes to callin.io/Day instead of callin.io/Day 1.

Inside your IF node expression you are mapping Contact Day from the airtable node Where Contact != Blank. I am guessing your airtable returns multiple items and by default the expression will map label item x to airtable item x, so your IF node might not compare the fields you are suspecting. We call this concept item linking.

If you’d want to use the first airtable item you could use an expression like this:
{{ $item(0).$node["Where Contact Day != Blank"].json["fields"]["Contact Day"] }}

To filter out gmail labels from a list of airtable items i would suggest using the code node with mode Run Once for All Items.

 
Posted : 09/12/2022 1:42 pm
ilya
 ilya
(@ilya)
Posts: 2
New Member
Topic starter
 

Hey,

Great shout - Quick question on Item Linking.
In my case, Airtable only returns one item.
However, it CAN return more than that.

Therefore, it returns something like [{object}] rather than {object}.

My labels field returns a number of labels that doesn’t correlate to the number of Airtable items.

So does callin.io do:
For each item in Labels array → Match Index against Airtable fields?
So we end up with Airtable[1] through to Airtable[n] being undefined?

In any case, you’ve helped me out, and I’m sure there’s a good design decision behind this concept.

For anyone Googling -
The below works for me.
I’ve also restructured my workflow slightly to be more pragmatic (pretty cool I run things async/have multiple inputs! Take that callin.io!)

const entry = $('Where Contact Day != Blank').item
return $('Get Labels').all().find(item => 
   item.json.name === 'callin.io/Day ' + entry.json.fields["Contact Day"]
)

Again, thanks for your help.

 
Posted : 09/12/2022 6:14 pm
system
(@system)
Posts: 332
Reputable Member
 

This thread was automatically closed 90 days following the last response. New replies are no longer permitted.

 
Posted : 09/03/2023 6:15 pm
Share: