Sub workflow isn't returning data

Describe the problem/error/question

I have a parent workflow which calls a sub-workflow.

As you can see, the sub-workflow is called and executed correctly, but there is no output data.

This is the sub-workflow.

If we open the last node, we can see the that the last node results 1 item.

I would expect that the output data should be returned to the main workflow. as described in the section “How data passes between workflows, item 2”

I’ve also toggled the setting “Wair For Sub-Workflow Completion” in the parent workflow without any success.

Does anybody know what I’m doing wrong?

I really appreciate any help you can provide.

Information on your n8n setup

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

hello @Jeroen_Janssen

The Code node can’t have multiple inputs. If you do so, then you may experience such an issues.
image

You should either make a logic to exclude the “empty” runs or use the Merge node to properly output results

1 Like

Hi @barn4k,

Thank you for your reply and valuable feedback.

I’ve removed one of the inputs from the code block.

If I look at the “false” output where I’ve placed the red arrow, the json is visible.

Unfortunately, the parent workflow did not receive that json output.

Is there something else I can try?

Thanks in advance!

1 Like

Your Merge node is waiting for two inputs to arrive, but it didn’t get the second one. Make it happy :slight_smile:

2 Likes

If you want to just return the false data add a node after it with only 1 output to make sure the output is in the first output. (for example no operation node)
It is now being returned as the second output(as you have noticed) and the execute workflow node only has 1 output making it not go further with that first output.
Hope that makes sense. :slight_smile:

But of course if you need to continue with the merge and everything @barn4k has posted a nice drawing of how to fix that :slight_smile:

1 Like

Hi @barn4k,

Again, thank you for your quick reply.

It is by design that the line is not connected. To give a bit more background of what I’m trying to do: This workflow requires an incoming invoice. It will check Harvest (bookkeeping application) if the invoice already exists, if not, it will create the expense and attach the invoice (pdf).

When the output of the IF statement is false, it means that the invoice already exists and I can skip all the next steps. So I have 2 successful outcomes:

  1. the invoice was new, and it will be added (true branch). I want to return success with the message “Invoice added”.
  2. the invoice already exists and all steps after the IF branch can be skipped. I want to return success with the message “Invoice already exists”.

The merge block to which you draw the line, is used to merge the json containing the ID that was just added in Harvest, together with the pdf (binary) which will be uploaded in the next step. So if no invoice needs to be added, only the binary is waiting on that merge.

Ok, back to the issue :slight_smile:
Do I need to add a merge block to have only one output? And if so, how can the merge block proceed if only one of the two inputs will ever be there?

Thanks, your answers are highly appreciated!

Hi @BramKn,

I’ve updated my workflow to add an additional node to merge the two outputs.

It’s still not returning the output to the parent workflow.

Maybe I did not correctly understand what you said?

Well, it acting weirdly because you have two outputs. The first one is the Code node where no data has been returned (and you see that in your master workflow because the node execution order was either from left to right or from up to bottom, so it was executed first), thus your second output has been thrown away.

Can you share the workflow itself? It will be much easier to help with it. All your credentials won’t be copied, only the workflow data.

As you have a bunch of Code nodes, you can remove the Merge nodes and make the workflow more linear (the Code node is able to work with any previously executed Nodes, as well as the Edit Fields node.

2 Likes

Hi @barn4k,

Here is the workflow. If you want I can share the other workflow as well, but I think this is the important one.

I wonder how to handle the IF statement correctly and have two outputs or, how to merge the two lines if only one will be executed.

As always, thank you for your reply!

As I don’t have access to the original data, there might be issues (I can’t test it).
The modified workflow is below

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