Logical AND and OR in Switch node

How to use logical operators in text field?

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • **n8n version: 1.80.3
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • **Operating system: Ubuntu 22.04

Hi @koordinator7

You have to switch the field to an expression for this to work

Additionally, the OR operator won’t work this way.

You need an expression that returns TRUE or FALSE.
Example:

Does that solve your problem?

I need to check that TEXT contains substring1 AND substring2, substring1 OR substring2

It doesn’t work like that because the expression of this type resolves to either true or false which is then gets converted into a string "true" or "false" and only then the node checks if this string contains "an".

You need switch to complete logical expressions in logical comparison context.
E.g.

Also if you want that “John” would trigger both outputs you need to turn on an option for this:

If this resolves your question, please mark this post as a :white_check_mark: Solution.

1 Like

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