Skip to main content

Nested Workflows in Torq: Improve Modularity and Reusability

Learn how to use nested workflows to improve your Torq workflows' efficiency, modularity, and scalability.

Updated yesterday

Use the Workflow operator to make complex workflows easier to read, more efficient, and simpler to maintain. It lets you break down big workflows into smaller, reusable parts.

Important to know

Nested workflows are triggered by the parent workflow and require the On-demand trigger. Set the Triggered from toggle:

  • Anywhere: The workflow can be triggered manually by the user from the canvas or through exposure in Torq Cases. It is also available as a nested workflow. The workflow counts toward the workspace workflow quota.

  • Nested only: This workflow can only be used within other workflows. The workflow counts toward the workspace nested workflow quota.

A published parent workflow runs the published version of nested workflows (unless an ID of a different revision was specified). If the parent workflow is a draft, it uses the latest version of the nested workflow, whether it's published or still a draft.

Nested workflow executions generate an Activity Log entry with the parent workflow as the event source.

How to use

  1. Create a nested workflow: Use one of the following options:

    • Create a workflow with an on-demand trigger. Then, incorporate it as a nested workflow by using the Workflow operator in the parent workflow. Learn more in the example below.

    • Select a group of steps in an existing workflow and click the Create workflow icon to turn them into a nested workflow.

  2. Trigger settings: Nested workflows run when triggered by the parent workflow and rely on an on-demand trigger. Open the trigger Properties panel and set the Triggered from toggle to Anywhere or Nested only.

Edit a nested workflow

To test a draft version of a nested workflow, the parent workflow must also be in draft mode. If the parent workflow is published, it will use the nested workflow's published version.

  1. Draft mode: Switch the parent workflow to draft mode.

  2. Edit: Make changes to the nested workflow.

  3. Test: Manually start the parent or nested workflows to test the executions.

  4. Publish: Publish the updated workflows.

Dependent workflows

When editing a workflow, verify if it’s nested in other workflows and review any parent dependencies to avoid execution issues.

  1. View dependent workflows: Click View Affected Workflows to see which parent workflows might be impacted by your edits.

    • If there are several layers of nested workflows, check each level similarly.

  2. Mitigate problems: Update any workflows that require changes due to your edits.

  3. Test: Run the workflows to test the changes. If testing a draft version of the nested workflow, ensure the parent workflow is also in draft mode.

  4. Publish: Once everything is tested and executes correctly, publish the updated workflows.

Execution options

  1. Open the Properties panel: In the parent workflow, open the nested workflow’s Properties panel.

  2. Select execution options: The following options can be set:

    • Ignore failure: By default, if a nested workflow fails, the parent workflow stops and shows a failure. If you choose Yes, the parent workflow will continue to run even if there's a problem with the nested workflow.

    • Wait for output: By default, the parent workflow waits until the execution of the nested workflow is complete before continuing. If you select No, both workflows will run at the same time. However, the main workflow might not get the results from the nested workflow right away.

Use case

In this example, the nested workflow will enrich an IP address.

Creating a nested workflow

  1. Create a new workflow, give it a meaningful name and select the On-demand trigger.

  2. Select the trigger in the canvas to add input parameters for passing the required data from the parent workflow to the nested workflow. This example uses a short-text field titled IP Address as the workflow aims to enrich an IP address.

  3. Implement the logic to enrich the IP address. Access the IP address by using:

    {{ $.event.ip_address }}

  4. Add the Exit operator and define the workflow output. This output will be accessible in the parent workflow upon the completion of the nested workflow execution.

Using the nested workflow in a parent workflow

The parent workflow executes the nested workflow as part of its logic, providing the necessary information and using the output in subsequent steps.

  1. Create the parent workflow and implement the required logic.

  2. Add the Workflow operator.

    1. Select a workflow to call as a nested workflow.

    2. Provide the values for the nested workflow input parameters.

  3. Access the nested workflow output in subsequent steps by using:

    {{ $.<nested_workflow_name>.<output_structure> }}

Did this answer your question?