Something is wrong with "equal to" & "not equal to" if logic

I’ve seen this happening a lot of times but the if logic does not work correct a lot of times, I am really not sure how does the below data returns “true”

This should return the data for false instead of true or I am missing something?

Welcome to the community @sovobih!

Honestly can not imagine that the IF-Node does not work correctly and never came across a case. After all, is the code very simple and it would mean that a lot of people would have broken workflows for a long time as there have been no changes to the IF-Node for a very long time. So that should have come up much earlier. We got a lot of reports like that in the past but it always turned out to be some misunderstanding. Just to be sure that this is not the case here, did I just test and all is working fine.

Incoming Data from a Function-Node:

And the true and false output of the IF-Node:


Here also the workflow for you to test yourself:

So best to check if the value you have in “Value 1” is really 0 (so the number). Important to remember that ‘0’ is not ‘"0’" (so a string), also not undefined and also not null.

Hi Jan,

Thanks for getting back. I totally understand that the code for if logic is pretty simple. I even tried the nodes you gave and these are returning proper results. One thing I would like to note is even if I try to run a test on my workflow it will return correct data most of the times, as of now this is only happening when a workflow is triggered using a webhook.

But I’ve definitely seen this not working in tests too in past as I totally remember setting up opposite option just because it was not giving the right output.

Can you share your workflow? is it possible that expression is resolving to a value that is not a number.

Hi,
I have same, and that is my issue sometimes, it resolves to value (Although it seems number), when I switch to text it totally works fine.

1 Like

As @Jorge_M mentioned is it a good idea to make sure that it is actually the expected type by converting the value to it.

If you want to be sure that it is a string you could do:

={{ $json["number"].toString() }}

If you want to make sure it is a number:

={{ parseFloat($json["number"]) }}