Sometimes you need to move a set of nodes to a separate sub-workflow in n8n and execute it by the main workflow. It allows to make your workflow more compact and also reuse it's part in other workflows. But how to test it properly without executing it by the main workflow?
So let's start with some simple sub-workflow. Of course the first node will be Execute Sub-workflow Trigger node:
Let's add some input field:
Now let's add Manual Trigger node which will be used for testing purposes:
Next we should do the trick - add two Edit Fields (Set) nodes, one is for test input and the other one will combine the input from both triggers:
Specify color field with some test value in Test Input node:
And include all the input fields in Combine Input node:
Let's try to execute this n8n sub-workflow:
And check the input of the last node:
So you can see the same color field value we specified in Test Input node as Combine Input node output. If we execute this sub-workflow by the main n8n workflow with some color input it will be available in Combine Input node output as well.
Regardless the way we trigger our sub-workflow (manually or by main workflow) Combine Input node will always have color field value (testing value or real input from the main n8n workflow).
In further nodes you can use Combine Input node to refer to input values:
You can find the template for the described approach here.
No comments:
Post a Comment