How to set output of If node

Describe the problem/error/question

I have a simple IF node. The false output for the node is a copy of the input. I didn’t select this behavior it seems to be a default.

The true output for the node is empty. If the input were simply copied to the output for true, that would meet my needs.

I don’t see any discussion about the output from IF nodes in the documentation. How can I access/ set/ use output on the true branch?

More generally, how does IF node treat its outputs?

What is the error message (if any)?

There is no error.

Please share your workflow

Share the output returned by the last node

Input to If node:

[
  {
    "output": {
      "isInvoice": "YES",
      "id": "AAMkADY3M2YxNTFkLTVjNTYtNGUyMC1iYzEyLTJlNDRiNDUyZTVmZgBGAAAAAADlhvYQib4qSomtPoqPyNNFBwDoOmRFRWNuR6_cdJelOOwOAAAAZlnoAADrFiUdN37aQ5X0pTL_mlFoAAszbNgPAAA="
    }
  }
]

false output

[
  {
    "output": {
      "isInvoice": "YES",
      "id": "AAMkADY3M2YxNTFkLTVjNTYtNGUyMC1iYzEyLTJlNDRiNDUyZTVmZgBGAAAAAADlhvYQib4qSomtPoqPyNNFBwDoOmRFRWNuR6_cdJelOOwOAAAAZlnoAADrFiUdN37aQ5X0pTL_mlFoAAszbNgPAAA="
    }
  }
]

true output

<empty>

Information on your n8n setup

  • I am running the latest version from the cloud
  • Database: default for the cloud
  • n8n EXECUTIONS_PROCESS default
  • Running n8n via cloud
  • Operating system: macOS, current version

Hello and welcome to the community!

You need to compare with YES, not "YES". The type of comparison chosen is the one for strings, so the node doesn’t need the value to be enclosed in quotation marks.
The wrong value is the reason that the valid looking data ends up in false branch.

The If node is designed in a way that all items that match the condition end up in true branch, the remaining will end up in false branch. You connect your next action to the true branch to process the items that match the condition.

Does the above make sense?

If this resolves your issue please mark this post as a Solution.

1 Like

It does make sense and better yet, it worked! Thanks

1 Like

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