IF Result = false then wrong value

Hi All!

I am making progress with N8N and have build multiple workflows. However there is always more to build ;).

I have extended my workflow which is triggered by a webhook and request an API and gets the data out of JSON. I have made a condition with IF to see if the order is planned. If planned then it goed to true other to false. The IF node works and I have one result in the False route.

The problem is in MySQL node after the false. The ID that is passed true is of a different order.
You can see in the result box that it is different than of the False result in the IF node.

2020_09_24_12_07_59_n8n_️_Vplan_Collections_to_Productie

The ID is the first ID of the True path.
Can anybody explain what is wrong here?

Code:

[quote=“heestp, post:1, topic:2435, full:true”]
Hi All!

I am making progress with N8N and have build multiple workflows. However there is always more to build ;).

I have extended my workflow which is triggered by a webhook and request an API and gets the data out of JSON. I have made a condition with IF to see if the order is planned. If planned then it goed to true other to false. The IF node works and I have one result in the False route.

The problem is in MySQL node after the false. The ID that is passed true is of a different order.
You can see in the result box that it is different than of the False result in the IF node.

2020_09_24_12_07_59_n8n_️_Vplan_Collections_to_Productie

The ID is the first ID of the True path.

Can anybody explain what is wrong here?

Code:

Hi @heestp! For the MySQL node connected to the false output of the IF node, can you change the expression in the Query field to UPDATE werkorders SET volgorde = 9999 WHERE vplan_id = "{{$json["id"]}}" and check if executing that works?

Thanks for the quick response!
However it still doesn’t work…

Hi @heestp, the Editor UI shows the first result from the IF node. However, the actual data pushed into MySQL should be correct with the expression I mentioned above. I just tried it locally and it works correctly.

You can check that by adding a Function node and connecting it to the false output which will show you the expected result in the terminal. Here’s the code for the Function node if you’d like to try that out:

console.log($json["id"]);
return items;

Hope that helps!

Hi Tanay,

It was passed wrongly to MySQL that s how I found out. I know have a SET (empty) node between the IF and MySQL and now it works.

1 Like

Great to hear that it worked out! Have fun! :slight_smile:

The $node always gets the data of the node from the first output, in this case true. If you want to simply use the data that gets sent into the node you can use $json instead.

So change $node['IF Planned'].json["id"] to $json["id"]

1 Like

Hi Jan,

As you can read above. I tried that and that did not help.
I now solved it with a work-around by placing a SET in between. The SET does nothing.

Yes, I saw that but ignoring that seemed nicer than me having to say “you are wrong check again”.

Example workflow:

Screenshot from 2020-09-24 18-33-29

Data of “Set True” after it got executed:

Data of “Set False” after it got executed:

Hi Jan and Tanay,

Thanks for the help! I found out that Janay was right. In the designer it shows the wrong value (see picture) but when you execute the workflow the correct (IF → False) data will be passed.

Here you can see the ID starting with 00867 but that is the first record of the true path.

So the problem is pure cosmetic in the designer.

Thanks for the patience guys!

Great! Yes, that is currently sadly one of many limitations of the editor. I hope we can improve that in the future to make that less confusing for people!

Have fun!

1 Like