<h2>Set Flow Variables 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 2025" /><meta name="DC.rights.owner" content="(C) Copyright 2025" /><meta name="generator" content="DITA-OT" /><meta name="DC.type" content="concept" /><meta name="DC.title" content="Set Flow Variables flow logic" /><meta name="abstract" content="Assign a value to one or more flow variables, which store flow data as data pills. Access flow variable values by referring to their data pill." /><meta name="description" content="Assign a value to one or more flow variables, which store flow data as data pills. Access flow variable values by referring to their data pill." /><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/workflow-studio/reference/workflow-studio.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/workflow-studio/reference/workflow-studio-reference.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-dynamic-flow.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/reference/exit-loop-flow-logic.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/reference/go-back-to-flow-logic.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/reference/skip-iteration-flow-logic.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-08-03" /><meta name="DC.date.modified" content="2024-08-01" /><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-set-flow-variables" /><link rel="stylesheet" type="text/css" href="../../../CSS/commonltr.css" /><title>Set Flow Variables flow logic</title></head><body id="flow-logic-set-flow-variables"> <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/workflow-studio/reference/workflow-studio.html" title="Consolidate workflow authoring, configuring, and monitoring into a single page experience. Create and manage playbooks, flows, actions, decision tables, and integrations from one design environment.">Workflow Studio</a> > <a class="link" href="../../../administer/workflow-studio/reference/workflow-studio-reference.html" title="Review additional information about Workflow Studio properties and component workflow applications.">Workflow Studio reference</a> > <a class="link" href="../../../administer/flow-designer/reference/flow-designer-reference.html" title="Get details about Workflow Studio flow components like actions, flow logic, and properties.">Flows, subflows, and actions reference</a> > </div> <h1 class="title topictitle1" id="ariaid-title1">Set Flow Variables flow logic</h1> <div class="body conbody"><p class="shortdesc"><span class="ph">Assign a value to one or more flow variables, which store flow data as data pills. Access flow variable values by referring to their data pill.</span></p> <div class="p"><div class="note important"><span class="importanttitle">Important:</span> This flow logic sets values for flow variables that have already been created. For instructions on creating flow variables, see <a class="xref" href="../task/create-flow-variables.html" title="Create a flow variable to store and retrieve a value throughout a flow.">Create a flow variable</a>.</div> </div> <div class="section" id="flow-logic-set-flow-variables__section_drb_fdt_jnb"><h2 class="title sectiontitle">Inputs</h2> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="flow-logic-set-flow-variables__table_m4w_ktt_jnb" class="table" frame="border" border="1" rules="all"><colgroup><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d118220e72">Field</th><th class="entry cellrowborder" style="vertical-align:top;" id="d118220e75">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d118220e72 ">Name</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d118220e75 ">Name of the variable. Select from the list of variables available for the flow.</td></tr><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d118220e72 ">Data</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d118220e75 ">Value for the variable. Enter a string value, input a script, or use a data pill. <span class="ph">Variable values can reference any data pill from earlier in the flow, including other variables. If you set variable values by reference to other data pills, you must maintain the order of the variable assignments. The referenced value must always come before the variable that uses the referenced value. Changing the order may produce null values.</span> To assign an empty value, leave this field empty.<div class="note"><span class="notetitle">Note:</span> <span class="ph">Flow variable values are set in the order in which they're assigned from top to bottom. If you set the value of the same variable multiple times, the flow only uses the last value set.</span></div> <p class="p">To enter a script, select the <span class="ph uicontrol">Toggle scripting on for [variable]</span> icon. Enter your script in the script editor. For more information about inline scripting, see <a class="xref" href="inline-scripts.html" title="Enable users with coding experience to write inline scripts that set and modify input values during the configuration of an action or flow. Use inline scripts to modify input values that require small format conversions, data transformations, or math operations.">Inline scripts</a>.</p> </td></tr></tbody></table> </div> </div> <div class="section" id="flow-logic-set-flow-variables__section_ipn_gdt_jnb"><h2 class="title sectiontitle">Outputs</h2> <p class="p">This flow logic produces no outputs but does change the value of flow variables.</p> </div> <div class="section" id="flow-logic-set-flow-variables__section_my2_bhv_qbc"><h2 class="title sectiontitle">Usage</h2> <p class="p">Flow variables store flow data as data pills of a specific data type. You can access flow variable data pills from the Flow Variables section of the Data pane. To use a flow variable value, select the data pill from the Data pane or the pill picker just as you would any other data pill.</p> </div> <div class="example" id="flow-logic-set-flow-variables__example_zv1_pdt_jnb"><h2 class="title sectiontitle">Set the incident number variable value to a flow data pill value</h2> <p class="p">In this example, the flow checks the category of an incident record. If the category is network, a flow variable is used to store the record number.</p> <p class="p"><img class="image" id="flow-logic-set-flow-variables__image_bfm_dkw_pnb" width="800" src="../images/set-flow-variables-flow-logic.png" alt="Use a data pill value to set a flow variable." /></p> <p class="p">Later in the flow, the Send Email action uses the incident number flow variable as part of the email subject and body.</p> <p class="p"><img class="image" id="flow-logic-set-flow-variables__image_zfl_www_qbc" src="../images/example-use-flow-variable-in-send-email.png" alt="Send Email action that uses the Flow Variable incident number in both the subject and body of the email." /></p> </div> <div class="example" id="flow-logic-set-flow-variables__example_jmh_z5k_wyb"><h2 class="title sectiontitle">Set the incident number variable value using a script</h2> <p class="p">In this example, the flow checks the category of an incident record. If the category is network, a flow variable is used to store the record number. In this example, the flow variable is set from a script rather than a data pill value.</p> <div class="p"><pre class="pre codeblock"><code>/* **Access Flow/Action data using the fd_data object. Script must return a value. **Order number is offset by +1 in Error Handling Section. **Available options display upon pressing "." after fd_data **example: var shortDesc = fd_data.trigger.current.short_description; **return shortDesc; */ var incNumber = fd_data.trigger.current.number; return incNumber;</code></pre></div> <p class="p"><img class="image" id="flow-logic-set-flow-variables__image_bbl_rvk_wyb" src="../images/flow-logic-set-flow-variables-script.png" alt="Use a script to set a flow variable." /></p> </div> <div class="section" id="flow-logic-set-flow-variables__section_cql_rdt_jnb"><h2 class="title sectiontitle">Execution details</h2> <div class="fig fignone" id="flow-logic-set-flow-variables__fig_tj1_kkw_pnb"><span class="figcap"><span class="fig--title-label">Figure 1. </span>Execution details for set the incident number variable value to a data pill value</span> <img class="image" id="flow-logic-set-flow-variables__image_uj1_kkw_pnb" width="800" src="../images/set-flow-variables-execution-details.png" alt="Example execution details of setting a flow variable with a data pill." /> </div> <div class="fig fignone" id="flow-logic-set-flow-variables__fig_gm5_ngl_wyb"><span class="figcap"><span class="fig--title-label">Figure 2. </span>Execution details for set the incident number variable value using a script</span> <img class="image" id="flow-logic-set-flow-variables__image_v15_ygl_wyb" src="../images/flow-logic-set-flow-variables-script-execution-details.png" alt="Example execution details of setting a flow variable with a script." /> <img class="image" id="flow-logic-set-flow-variables__image_hm5_ngl_wyb" alt="Example execution details of setting a flow variable with an inline script." /> </div> </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.">Workflow Studio 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-dynamic-flow.html" title="Identify and run a flow or subflow dynamically by using runtime data. Build templates to provide expected inputs for dynamically called flows or subflows.">Dynamic flows 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-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 class="linklist relinfo relref"><strong>Related reference</strong><br /> <ul class="linklist"><li class="linklist"><a class="link" href="../../../administer/flow-designer/reference/exit-loop-flow-logic.html" title="Exit from a flow logic loop when the conditions of an If flow logic are met. Continue running the flow from the next step after the flow logic loop. This flow logic is also known as break.">Exit Loop flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/reference/go-back-to-flow-logic.html" title="Return to a prior step in the flow to repeat a sequence of actions.">Go back to flow logic</a></li><li class="linklist"><a class="link" href="../../../administer/flow-designer/reference/skip-iteration-flow-logic.html" title="Skip the current iteration of a flow logic loop when the conditions of an If flow logic are met. Continue running the flow logic loop with the next item in the list. This flow logic is also known as continue.">Skip Iteration flow logic</a></li></ul></div> </div></body></html></div>