<h2>Dynamic flows flow logic</h2><br/><div style="overflow-x:auto"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta content="text/html; charset=UTF-8" /><meta name="copyright" content="(C) Copyright 2024" /><meta name="DC.rights.owner" content="(C) Copyright 2024" /><meta name="generator" content="DITA-OT" /><meta name="DC.type" content="concept" /><meta name="DC.title" content="Dynamic flows flow logic" /><meta name="abstract" content="Identify and run a flow or subflow dynamically by using runtime data. Build templates to provide expected inputs for dynamically called flows or subflows." /><meta name="description" content="Identify and run a flow or subflow dynamically by using runtime data. Build templates to provide expected inputs for dynamically called flows or subflows." /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/build-workflows/concept/build-workflows.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-designer.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/reference/flow-designer-reference.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-assign-subflow-outputs.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-call-workflow.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-do-until.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-do-following-in-parallel.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-end-action.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-for-each.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-if.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-make-decision.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-set-flow-variables.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-try.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/flow-designer/concept/flow-logic-wait-for-a-duration.html" /><meta name="DC.creator" content="ServiceNow" /><meta name="DC.date.created" content="2023-02-02" /><meta name="DC.date.modified" content="2023-02-02" /><meta name="page-type" content="automation-engine" /><meta name="page-type" content="platform" /><meta name="mini-toc" content="yes" /><meta name="DC.format" content="XHTML" /><meta name="DC.identifier" content="flow-logic-dynamic-flow" /><link rel="stylesheet" type="text/css" href="../../../CSS/commonltr.css" /><title>Dynamic flows flow logic</title></head><body id="flow-logic-dynamic-flow"> <div class="breadcrumb"><a class="link" href="../../../administer/build-workflows/concept/build-workflows.html" title="Transform manual tasks and mundane work into digital workflows. Modernize legacy processes with hyperautomation. Enable citizen automation from one platform.">Build workflows</a> > <a class="link" href="../../../administer/flow-designer/concept/flow-designer.html" title="Flow Designer is a Now Platform feature that enables process owners to automate work. Build multi-step flows from reusable components without having to code.">Flow Designer</a> > <a class="link" href="../../../administer/flow-designer/reference/flow-designer-reference.html" title="Get details about Flow Designer components like actions, flow logic, and properties.">Flow Designer reference</a> > </div> <h1 class="title topictitle1" id="ariaid-title1">Dynamic flows flow logic</h1> <div class="body conbody"><p class="shortdesc"><span class="ph">Identify and run a flow or subflow dynamically by using runtime data. Build templates to provide expected inputs for dynamically called flows or subflows.</span></p> <p class="p">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.</p> <div class="p">To use Dynamic Flow, the flow designer does the following:<ol class="ol" id="flow-logic-dynamic-flow__ol_j2d_jwt_mjb"><li class="li">Creates and publishes a flow or subflow to use as a template.</li><li class="li">Adds Dynamic Flow to a parent flow.</li><li class="li">Selects the flow template for Dynamic Flow.</li><li class="li">Enters the flow name for Dynamic Flow.</li><li class="li">Enters the required inputs specified by the flow template.</li></ol> </div> <div class="section" id="flow-logic-dynamic-flow__section_tlx_1xt_mjb"><h2 class="title sectiontitle">Dynamic flow templates</h2> <p class="p">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 <span class="ph uicontrol">Label</span> and <span class="ph uicontrol">Name</span> field values in each flow or subflow.</p> <p class="p">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 <a class="xref" href="../task/getting-started-dynamic-flow-get-flow-outputs.html" title="Create a sample flow that dynamically calls subflows for provisioning cloud services.">Getting started with Dynamic Flow and Get Flow Outputs</a>.</p> </div> <div class="section" id="flow-logic-dynamic-flow__section_vlc_xyt_y3b"><h2 class="title sectiontitle">Inputs</h2> <p class="p">The following inputs always appear when you add the Dynamic Flow flow logic to a flow.</p> <div class="p"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="flow-logic-dynamic-flow__table_zmj_tzt_y3b" class="table" frame="border" border="1" rules="all"><colgroup><col style="width:50%" /><col style="width:50%" /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d245159e112">Input</th><th class="entry cellrowborder" style="vertical-align:top;" id="d245159e115">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d245159e112 "><span class="ph uicontrol">Flow Template</span></td><td class="entry cellrowborder" style="vertical-align:top;" headers="d245159e115 ">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.</td></tr><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d245159e112 "><span class="ph uicontrol">Flow</span></td><td class="entry cellrowborder" style="vertical-align:top;" headers="d245159e115 "><p class="p">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.</p> <p class="p">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.</p> <div class="note"><span class="notetitle">Note:</span> If the system can't find the flow or subflow, it skips the <span class="ph uicontrol">Dynamic Flow</span> flow logic step and logs an error message.</div> </td></tr><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d245159e112 "><span class="ph uicontrol">Wait for completion</span></td><td class="entry cellrowborder" style="vertical-align:top;" headers="d245159e115 ">Option to force the parent flow to wait until the dynamic flow finishes running before proceeding with the next action.</td></tr></tbody></table> </div> <div class="note"><span class="notetitle">Note:</span> You see more inherited inputs after you select a <span class="ph uicontrol">Flow Template</span>.</div> </div> </div> <div class="section" id="flow-logic-dynamic-flow__section_x1v_zkt_1jb"><h2 class="title sectiontitle">Get flow outputs</h2> <div class="p">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:<ol class="ol" id="flow-logic-dynamic-flow__ol_d1t_cc5_mjb"><li class="li">Adds a Dynamic Flow to a flow.</li><li class="li">Adds Get Flow Outputs after the dynamic flow.</li><li class="li">Specifies the value for the <span class="ph uicontrol">Context</span> input by clicking the data pill picker (<img class="image icon" id="flow-logic-dynamic-flow__image_hhf_5bg_mjb" src="../images/data_pill_picker.png" alt="Data pill picker" />) and selecting <span class="ph menucascade"><span class="ph uicontrol">Dynamic Flow</span> > <span class="ph uicontrol">Context</span></span>.</li></ol> </div> <p class="p">For more information on using Get Flow Outputs, see <a class="xref" href="../task/getting-started-dynamic-flow-get-flow-outputs.html" title="Create a sample flow that dynamically calls subflows for provisioning cloud services.">Getting started with Dynamic Flow and Get Flow Outputs</a>.</p> </div> <div class="section" id="flow-logic-dynamic-flow__id_vgy_jtb_ptb"><h2 class="title sectiontitle">Design considerations</h2> <dl class="dl"><dt class="dt dlterm">Use dynamic flows if you have multiple subflows with similar functionality</dt><dd class="dd">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 <a class="xref" href="../administer/integrationhub/concept/integrationhub.dita/integrationhub.html" target="_blank" rel="noopener noreferrer">IntegrationHub</a> spokes.</dd><dt class="dt dlterm">Ensure dynamically called subflow inputs match template flow inputs</dt><dd class="dd">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.</dd><dt class="dt dlterm">Use the correct context when getting flow outputs</dt><dd class="dd">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.</dd></dl> </div> </div> <div class="related-links"> <div class="familylinks"> <div class="parentlink"><strong>Parent Topic:</strong> <a class="link" href="../../../administer/flow-designer/concept/flow-logic.html" title="Enable flows and subflows to specify conditional or repeated actions. Combine the elements of flow logic to create workflows in a graphical interface with little or no scripting.">Flow Designer flow logic</a></div> </div> <div class="linklist relinfo relconcepts"><strong>Related concepts</strong><br /> <ul class="linklist"><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-assign-subflow-outputs.html" title="Specify the data the subflow returns when it completes running. Use subflow output as data for a parent flow or as input for another process.">Assign subflow outputs flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-call-workflow.html" title="Run a published and active workflow from your flow. You can use the flow data as a workflow input. For example, you can specify the current record as a workflow input.">Call a workflow flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-do-until.html" title="Apply one or more actions repeatedly until an end condition is met. You can use the flow data to specify the end conditions.">Do the following until flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-do-following-in-parallel.html" title="Run actions and subflows in separate paths within an isolated flow logic block.">Do the following in parallel flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-end-action.html" title="Stop running the current flow. Use End Flow within a branch of the flow to specify an exit condition. For example, end the flow when it reaches a specific If flow logic block.">End Flow flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-for-each.html" title="Apply one or more actions to each record in a list of records.">For Each flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-if.html" title="Selectively apply one or more actions only when a list of conditions is met.">If flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-make-decision.html" title="You can use the decision table branching logic in situations where multiple conditional paths are required, as an alternative to nested If, Else If, or Else flow logic. For example, if you want to determine what kind of car insurance you need, you can add inputs such as your age, accident history, and car model to the decision table to determine a level of insurance coverage. This logic can save you time and present a more readable format than nested if conditions or switch case statements.">Make a decision flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-set-flow-variables.html" title="Assign a value to one or more flow variables. Change or update a variable's value during a flow.">Set Flow Variables flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-try.html" title="Allow a flow to continue running when an error occurs within a flow logic block. Run a sequence of actions in response to errors within the flow logic block.">Try flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/concept/flow-logic-wait-for-a-duration.html" title="Use this flow logic to give your users time to act during automated processes or to wait for a specific date and time to complete actions.">Wait for a duration flow logic</a></li></ul></div> </div></body></html></div>