Dynamic flows flow logic

  • Release version: Zurich
  • Updated July 31, 2025
  • 3 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Dynamic Flows Flow Logic

    Dynamic Flows flow logic enables ServiceNow customers to dynamically identify and run a flow or subflow at runtime using specified data. This capability allows you to select which flow to execute when multiple flows have similar names or purposes, enhancing process flexibility and reuse.

    Show full answer Show less

    How It Works

    • Create and publish a flow or subflow as a template with defined inputs.
    • Add the Dynamic Flow logic to a parent flow, select the flow template, and specify the flow name or Sys ID to run dynamically.
    • Enter required inputs matching those defined in the template to ensure compatibility.

    Dynamic Flow Templates

    Templates can be either flows or subflows, and their inputs must match those of any dynamically called flow or subflow by having the same label and name values. Use templates to build standardized flows or subflows and apply naming conventions to enable dynamic generation of flow names.

    Key Inputs

    • Flow Template: The template whose inputs are copied and must align with the dynamic flow inputs.
    • Flow Name or Sys ID: The display name of the flow or subflow to execute dynamically. Names can be generated dynamically by concatenating strings with data pills, and you can specify application scopes if needed.
    • Wait for Completion: Optionally make the parent flow wait until the dynamic flow finishes before proceeding.

    Note: If the flow or subflow cannot be found, the step is skipped and an error is logged.

    Getting Flow Outputs

    Dynamic Flow outputs appear as Record type data pills named Context. To retrieve runtime output values, use the Get Flow Outputs flow logic by specifying the correct Context data pill from the dynamic flow run. When running dynamic flows multiple times, ensure the correct context record is selected for each output retrieval.

    Best Practices

    • Use dynamic flows to manage multiple subflows with similar functionality, improving modularity and reducing duplication.
    • Ensure inputs of the dynamically called flow and the template match exactly to prevent runtime errors.
    • Select the appropriate context when retrieving outputs, especially when multiple dynamic flows are run in the same parent flow.

    Practical Benefits

    By leveraging Dynamic Flows, ServiceNow customers can create flexible, maintainable flows that dynamically determine the next execution steps based on runtime data. This approach supports complex automation scenarios where similar processes are handled via templated flows and subflows, streamlining flow design and runtime decision-making.

    Identify and run a flow or subflow dynamically by using runtime data. Build templates to provide expected inputs for dynamically called flows or subflows.

    The Dynamic Flow flow logic calls a flow or subflow during runtime by using the data that you specify during the flow design. You can use Dynamic Flow to select which flow to run when multiple flows have similar names or purposes.

    To use Dynamic Flow, the flow designer does the following:
    1. Creates and publishes a flow or subflow to use as a template.
    2. Adds Dynamic Flow to a parent flow.
    3. Selects the flow template for Dynamic Flow.
    4. Enters the flow name for Dynamic Flow.
    5. Enters the required inputs specified by the flow template.

    Dynamic flow templates

    The template for Dynamic Flow can be a flow or a subflow. The template's inputs must match the inputs of any flow or subflow that you call dynamically. An input matches when it has the same Label and Name field values in each flow or subflow.

    After you build a template, consider copying it to create similarly named and similarly performing flows or subflows. Make sure that you name each flow or subflow with a standard naming convention that can be generated by Dynamic Flow. For more information on creating a template for Dynamic Flow, see Getting started with Dynamic Flow and Get Flow Outputs.

    Inputs

    The following inputs always appear when you add the Dynamic Flow flow logic to a flow.

    Input Description
    Flow Template Template whose inputs the dynamic flow copies and displays. The inputs for the template must match the inputs of the subflow that you want to run.
    Flow

    Name or Sys ID of the flow or subflow that you want to run. Flow names must be the display name not the flow internal name. For example, enter the name My dynamic flow not my_dynamic_flow. Generate a flow or subflow name dynamically by entering a string and concatenating it with data pill values.

    You can call a flow or subflow that is associated with another application scope by entering a scope-name.flow-name format. The user running the flow or subflow must have access to the application scopes that you specify. If you do not specify an application scope, the dynamic flow runs in the parent flow's scope.

    Note:
    If the system can't find the flow or subflow, it skips the Dynamic Flow flow logic step and logs an error message.
    Wait for completion Option to force the parent flow to wait until the dynamic flow finishes running before proceeding with the next action.
    Note:
    You see more inherited inputs after you select a Flow Template.

    Get flow outputs

    Dynamic Flow outputs appear in the data panel as Record type data pills that are named as Context. You can use these flow contexts to derive the runtime values for dynamic flow outputs with the Get Flow Outputs flow logic. To use Get Flow Outputs, the flow designer does the following:
    1. Adds a Dynamic Flow to a flow.
    2. Adds Get Flow Outputs after the dynamic flow.
    3. Specifies the value for the Context input by clicking the data pill picker (Data pill picker) and selecting Dynamic Flow > Context.

    For more information on using Get Flow Outputs, see Getting started with Dynamic Flow and Get Flow Outputs.

    General guidelines

    Use dynamic flows if you have multiple subflows with similar functionality
    Dynamic flows let you compartmentalize your processes by applying a template to handle the inputs of multiple similar subflows. Compartmentalization lets you distinguish between subflows that perform similar functions, such as subflows for IntegrationHub spokes.
    Ensure dynamically called subflow inputs match template flow inputs
    The system throws an error and the main flow can't run properly when the inputs of a dynamic flow and flow template don't match.
    Use the correct context when getting flow outputs
    A context record uniquely identifies the flow run. If you run a dynamic flow multiple times, there are multiple context records to choose from. When you use dynamic flow multiple times within a flow, make sure to pick the right context record from the right run each time you get flow outputs.