Set node: [ERROR: No data found for item-index: "0"]

Depending if a customer exists or not, I have put an IF node in the workflow. If the customer doesn’t exist it gets created, if not, I want to proceed with the existing one.

For further usage I try to set the customer id “Kundennummer” in the “Kunde” node. Unfortunately it only works when the IF node is false. Otherwise it is giving me
[ERROR: No data found for item-index: "0"]

Can anyone help me with the syntax of the SET node?

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:

Sorry, I thought this is needed because it isn’t related to the topic:

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

Hey @mokkin,
there might be a more easy solution for that kind of cases. I think it is not possible to get the decision data from the if node.

So what i do in that cases is to introduce a set node at the end of both branches to output the needed value to a consolidation node.

In the set nodes at the end of the branch you set “Kundennummer” depending on the newly created one or the old one.

You would need the consolidation node to reference to “Kundennummer” safely later in the workflow.

This is an example flow for safely accessing urls if they are not always set in the beginning:

Generating new urls is the same as creating new “Kunden” in your workflow.

Hope that helps.

Cheers.

3 Likes

Your answer was just incredible and such an easy solution after all!

I applied it directly to my workflow and it worked out of the box!

Thank you very much @nico-kow :+1: :pray:

Considering that the name of the parameter is always the same Id there is not an even simpler solution. Instead of the original:

{{
  $node["IF"].json["condition"] === true
  ? $('Kunde anlegen').item.json.Id
  : $('Kunde suchen').item.json.Id
}}

in the Node Kunde simply the following can be used:

{{ $json.Id` }}

Which means, take the property Id of the incoming data, no matter from which node it comes.

1 Like

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