diff --git a/_snippets/flow-logic/subworkflow-data-flow.md b/_snippets/flow-logic/subworkflow-data-flow.md index 79c3898a9a9..518c247d53e 100644 --- a/_snippets/flow-logic/subworkflow-data-flow.md +++ b/_snippets/flow-logic/subworkflow-data-flow.md @@ -1,4 +1,4 @@ -For example, there's an Execute Workflow node in **Workflow A**. The Execute Workflow node calls another workflow, **Workflow B**: +As an example, imagine you have an Execute Workflow node in **Workflow A**. The Execute Workflow node calls another workflow called **Workflow B**: 1. The Execute Workflow node passes the data to the Execute Workflow Trigger node of **Workflow B**. 2. The last node of **Workflow B** sends the data back to the Execute Workflow node in **Workflow A**. diff --git a/_snippets/flow-logic/subworkflow-usage.md b/_snippets/flow-logic/subworkflow-usage.md index c2d7d7bc5a8..7a986f6230f 100644 --- a/_snippets/flow-logic/subworkflow-usage.md +++ b/_snippets/flow-logic/subworkflow-usage.md @@ -1,25 +1,38 @@ ### Create the sub-workflow + 1. Create a new workflow. + + /// note | Create sub-workflows from existing workflows + You can optionally create a sub-workflow directly from an existing parent workflow using the [Execute Workflow](/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow/) node. In the node, select the **Database** and **From list** options and select **Create a sub-workflow** in the list. + /// + 1. **Optional**: configure which workflows can call the sub-workflow: 1. Select the **Options** ![Options menu](/_images/common-icons/three-dot-options-menu.png){.off-glb} menu > **Settings**. n8n opens the **Workflow settings** modal. 1. Change the **This workflow can be called by** setting. Refer to [Workflow settings](/workflows/settings/) for more information on configuring your workflows. 1. Add the **Execute Workflow Trigger** node. -1. Add other nodes as needed to build your sub-workflow functionality. +1. Set the **Input data mode** to choose how you will define the sub-workflow's input data: + * **Define using fields below**: Choose this mode to define individual input names and data types that the calling workflow needs to provide. + * **Define using JSON example**: Choose this mode to provide an example JSON object that demonstrates the expected input items and their types. + * **Accept all data**: Choose this mode to accept all data unconditionally. The sub-workflow won't define any required input items. This sub-workflow must handle any input inconsistencies or missing values. +1. Add other nodes as needed to build your sub-workflow functionality. 1. Save the sub-workflow. /// note | Sub-workflow mustn't contain errors -If there are errors in the sub-workflow, the parent workflow can't trigger it. +If there are errors in the sub-workflow, the parent workflow can't trigger it. /// /// note | Load data into sub-workflow before building -This requires the ability to [load data from previous executions](/workflows/executions/debug/), which is available to Pro and Enterprise users. +This requires the ability to [load data from previous executions](/workflows/executions/debug/), which is available on n8n Cloud and registered Community plans. If you want to load data into your sub-workflow to use while building it: 1. Create the sub-workflow and add the **Execute Workflow Trigger**. +1. Set the node's **Input data mode** to **Accept all data** or define the input items using fields or JSON if they're already known. 1. In the sub-workflow [settings](/workflows/settings/), set **Save successful production executions** to **Save**. 1. Skip ahead to setting up the parent workflow, and run it. 1. Follow the steps to [load data from previous executions](/workflows/executions/debug/). +1. Adjust the **Input data mode** to match the input sent by the parent workflow if necessary. + You can now pin example data in the trigger node, enabling you to work with real data while configuring the rest of the workflow. /// @@ -34,6 +47,9 @@ You can now pin example data in the trigger node, enabling you to work with real Your sub-workflow's ID is the alphanumeric string at the end of its URL. /// +1. Fill in the required input items defined by the sub-workflow. 1. Save your workflow. When your workflow executes, it will send data to the sub-workflow, and run it. + +You can follow the execution flow from the parent workflow to the sub-workflow by opening the Execute Workflow node and selecting the **View sub-execution** link. Likewise, the sub-workflow's execution contains a link back to the parent workflow's execution to navigate in the other direction. diff --git a/docs/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow.md b/docs/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow.md index ed8850da56c..c0456a6d98c 100644 --- a/docs/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow.md +++ b/docs/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow.md @@ -16,7 +16,8 @@ Use the Execute Workflow node to run a different workflow on the host machine th Select where the node should get the sub-workflow's information from: -- **Database**: Select this option to load the workflow from the database by ID. You must also enter: +- **Database**: Select this option to load the workflow from the database by ID. You must also enter either: + - **From list**: Select the workflow from a list of workflows available to your account. - **Workflow ID**: Enter the ID for the workflow. The URL of the workflow contains the ID after `/workflow/`. For example, if the URL of a workflow is `https://my-n8n-acct.app.n8n.cloud/workflow/abCDE1f6gHiJKL7`, the **Workflow ID** is `abCDE1f6gHiJKL7`. - **Local File**: Select this option to load the workflow from a locally saved JSON file. You must also enter: - **Workflow Path**: Enter the path to the local JSON workflow file you want the node to execute. @@ -25,6 +26,14 @@ Select where the node should get the sub-workflow's information from: - **URL**: Select this option to load the workflow from a URL. You must also enter: - **Workflow URL**: Enter the URL you want to load the workflow from. +### Workflow Inputs + +If you select a sub-workflow using the **database** and **From list** options, the sub-workflow's input items will automatically display, ready for you to fill in or map values. + +You can optionally remove requested input items, in which case the sub-workflow receives `null` as the item's value. You can also enable **Attempt to convert types** to try to automatically convert data to the sub-workflow item's requested type. + +Input items won't appear if the sub-workflow's Workflow Input Trigger node uses the "Accept all data" input data mode. + ### Mode Use this parameter to control the execution mode for the node. Choose from these options: