Workflow is backflowing

Hello,

I have just started using the self-hosted version of n8n v1.52.2. I created a workflow to connect Google Sheets to Zammad Help Desk. When new rows are added to the sheet, it will trigger the workflow. The rows contain user information requesting a communications plan for a particular area. When a request comes in, I would like for a ticket to be created. But I also want the user to be created in Zammad if that user does not exist.

Now, I did run into an unexpected issue. I initially attempted to use an IF node to create the ticket if the user exists, or to first create the user, then the ticket if the user did not already exist. However, the IF node does not pass along data from previous nodes unless the output is True. Nodes connected to the False output do not get any data from any previous node. Since I still need both outputs to pass data from the trigger node, I had to place two IF nodes and make them duplicate opposites so that the desired effect passes along the True output. This seems to work well, and tickets are being created.

But I noticed an even more unexpected problem for when the customer already exists in Zammad. The workflow gets to the end, creates the ticket, then backflows in reverse down the other path to the Create User node. Since the user already exists, it of course generates an error. So, I removed the path from Create User to Create Ticket and duplicated the Create Ticket Node, so that the 2 paths remain separate. But the workflow would still jump from the end of one path to the Create User node, even when separated.

The workflow still performs the desired task overall, but not in a clean way. Ideally, I would like to have 1 IF node, diverge to either create the user or update contact info, and then create the ticket with no backflows.

And no, I did not notice that I had misspelled “Exists” on node 2, LOL. Thank you in advance for any assistance you can provide.

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.52.2
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): I did not define it during install, so default I guess
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu 24.04

The data is passed over either via “true” output or “false” output whichever is applicable. Just to demonstrate it, here’s a very simple workflow:

There are two items produced by Code node. The IF node will let one item through to the “true” output and the other to “false” output (as per condition set up in IF node).

That is only the case when the condition always validates to true. For the item to go through to “false” output the condition has to be false.

That sounds to me as if there is a bug in your workflow setup. Let’s review your requirements

When new rows are added to the sheet, it will trigger the workflow. The rows contain user information requesting a communications plan for a particular area. When a request comes in, I would like for a ticket to be created. But I also want the user to be created in Zammad if that user does not exist.

It sounds straightforward to me. It appears the node “Check if Customer Exists” is responsible for checking the user existence. However, it is not clear what that node returns when the user exists and when it doesn’t. This is because the conditions in both IF nodes do not fully correlate to know for sure.

I do believe that only one If node has to be sufficient. It is only a matter of configuring it correctly.

It also appears there is an extra requirement as you also have the node to “Update user” when it exists. The updates are coming from the Google form.

With the said above, lets take a close look at your IF node configurations. The “If True” node has the following condition:

  • email exists
    AND
  • email is the same as in the Google form

The “If False” node, however, has only

  • email is not the same as in the Google form

But “If False” node also has “Always Output Data”. That prompts for a situation when both IF nodes would have an item at true output.

Here’s the demonstration of this condition

The important difference is the “If False” produces an empty item ({}) but it is there nonetheless which triggers execution of “Create User” node, which rightfully fails as no user is provided.

That is not true. As per explanation above, the 1st branch gets executed since the user exists, that is the user gets updated and ticket created. However, the “user does not exist” also get activated due to misconfiguration of the 2nd node, which in turn results in the failed “Create User” node.

Solution

I still believe that one IF node is sufficient. The problem stems from the item auto-reference. The branching breaks the auto-detection of the data in the preceding GoogleSheet node. To fix it, you need to reference the data by different means, see Output of other nodes | n8n Docs (aka manually since auto-reference with item will not work after branching, see Item linking concepts | n8n Docs).

If the Google Sheet trigger produces only one item then you can reference it in the Zammad nodes in this fashion, {{ $('Google Sheets Trigger').first().json['E-Mail Address'] }}. Note that I have replaced item with first().

Do check that all items have been replaced with first() assuming the trigger always produces one item.

3 Likes

@ihortom, thank you so much for taking the time to clearly explain the issue I was having, and for providing the link references. The workflow now works correctly, and with one IF node.

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