Sub-workflow
Overview
Complex workflows can be separated into smaller sections called sub-workflows (or child workflows) to make them more manageable. Sub-Workflows are workflows that run in the context of another (parent) workflow. Multiple sub-workflows and multiple levels of nested workflows that is, sub-workflow within a sub-workflow) can exist in a single parent workflow.. When a parent workflow's path reaches a sub-workflow, the objects that are contained in the sub-workflow (from the first to the last object, according to the sub-workflow's path) are executed.
You can embed new, unbuilt workflows into a parent workflow or embed pre- existing workflows currently stored in the repository. Workflow Designer enables you to visually create, examine and debug embedded workflows. Double-clicking an embedded workflow adds a new tab to the workspace allowing you to easily switch from the workflow and sub-workflow view (as shown below). During execution, when a parent workflow's path reaches a sub-workflow, a new tab appears in the main workspace allowing you to view the graphical flow of objects contained in the sub-workflow. Additionally, single-clicking an embedded workflow object will show a preview image of that workflow.
To add a new sub-workflow
-
From Workflow Designer, drag the workflow object from the Objects panel onto the workspace. A new workflow icon with a default name of "Unbuilt Workflow" appears in the workspace. Click the default name to rename the workflow.
-
Double-click the workflow or right-click and select Edit to add/edit objects for the workflow. A new tab is opened corresponding to the new workflow.
-
After editing the new workflow:
-
Select Updatein the ribbon to update the current workflow. This will update only the current workflow.
-
Select Update All and Exit to update all the open workflows and exit the WFD.
-
Select Close on the ribbon or X in the top-right corner of the main tab control to close the current workflow.
-
-
From the parent workflow, add the appropriate arrows to point to/from the sub-workflow.
To use an existing workflow as a sub-workflow
-
From the Workflow Designer, select Repository.
-
From the repository window that appears expand the Workflows folder and drag the desired workflow to the workspace.
-
Double-click the workflow or right-click and select Edit to edit the workflow. A new tab appears corresponding to that workflow.
-
After editing the workflow:
-
Select Update in the ribbon to update the current workflow. This will update only the current workflow.
-
Select Update All and Exit to update all the open workflows and exit the WFD.
-
Select Close on the ribbon or X in the top-right corner of the main tab control to close the current workflow.
-
-
From the parent workflow, point flow control arrows to/from the sub-workflow.
-
When debugging a workflow that contains a sub-workflow, upon execution of that workflow, a new tab will be opened and the items in that workflow are highlighted as they run.
-
Hovering over a sub-workflow will show a preview image of that workflow.
To preview a sub-workflow
- On the Workflow Designer workspace, select the sub-workflow object you wish to preview. Doing so adds a new Preview button to the Output/Shared objects panel.
-
Select Preview. A preview of the sub-workflow appears in the Output/Shared objects panel (as shown below).
Behavior
A sub-workflow's behavior can be altered depending on specific settings or conditions. Certain objects can be used to determine the behavior of a sub-workflow as well. Below are some rules to consider when using sub-workflows.
Sub-workflows containing triggers
Only parent workflows are capable of starting automatically. This is because triggering events or conditions (conditions used to start the workflow) are active only in the parent workflow. If a sub-workflow contains a triggering condition, that condition will be ignored.
Shared variables
To follow the conventions established with tasks and sub-tasks, shared variables are capable of being passed between parent and sub-workflows. Parameters located in the Advanced tab of the shared variable's properties dialog can affect its behavior when being passed to a sub-workflow and vice versa. They are as follows:
-
Pass the value from the Parent Workflow to this variable when this workflow starts, overriding this variable's initial value - If enabled, the value of the shared variable that resides in the parent workflow is allowed to be passed to any embedded workflow (or sub-workflow). The value passed from the parent workflow will override any initial value that the variable is set to. If disabled, the value of the shared variable is only available to the parent workflow and will not be passed to the sub-workflow (disabled by default).
-
Pass the value from this variable to the Parent Workflow when this workflow finishes - If enabled, the value of a shared variable encompassed in the embedded or sub- workflow is allowed to propagate back to the parent workflow upon the embedded workflow’s completion. If disabled, the shared variable’s value will not be passed to the parent workflow.
Only shared variables with the same name (case not important) are passed between parent and sub-workflows and vice versa when the settings permit (disabled by default).
System agents
The current system agent values of the TriggeringAgent, PreviousAgent, and ConditionAgent of the parent workflow are set in the embedded workflow when it runs. The DefaultAgent of the embedded workflow remains the same. The value of PreviousAgent is not propagated to the parent workflow upon sub-workflow execution completion. A sub-workflow executes within a parent workflow if it was run manually (that is, any triggering conditions are ignored, and any workflow item with no parent items execute). For more details, see System Agents.
AMWorkflow
When a sub-workflow runs in the context of another workflow, an Automate dataset called AMWorkflow is automatically created. This dataset can be used at the parent workflow level to determine specific behavioral characteristics regarding the sub-workflow, such as the name, unique ID and execution results. AMWorkflow is a standard Automate dataset and can be used much like the datasets created by the SQL Query and Get E-Mail action. For more details, see AMWorkflow