Issues with the if node

Hey, is someone able to explain whats happening with the if node here

image

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hi @samp

Not sure what you are doing here. But if you are simply checking that data field then you should change it to

$json.data.includes(‘plot_assistant’)

or

$json.data

And then change the If check to string with contains and then the text you search for in the second value.

Hi @BramKn

Thank you for your feedback here,

The code node returns and array of objects, im using the if node to check if any of the objects contain an action plot assistant, this expression works fine.

The issue ive got is with the if node, as you can see in the screenshot this expression resolves to false but somehow the output is true

Hey @samp

You shouldn’t have to use the second .json in your .map() function.

So instead of

{{ $json.actions.map(action => action.json.action).includes('plot_assistant') }}

it should be like this:

{{ $json.actions.map(item => item.action).includes('plot_assistant') }}

See the example below which is working correctly:

2 Likes

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