{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":48001,"path":"servicenow-platform/metricbase/assign-trigger-to-workflow.md","title":"Assign a trigger to a flow","bundle":null,"doc_type":null,"release":"australia","body":"\n# Assign a trigger to a flow\n\nNow that you created a trigger, use Workflow Studio to specify the flow a trigger executes. The flows can provide alerts for unexpected behavior.\n\n## Before you begin\n\nRole required: admin\n\n## About this task\n\nTriggers, by themselves, execute nothing. After defining a trigger in MetricBase, you use Workflow Studio to associate the trigger with a flow.\n\n## Procedure\n\n1.  Navigate to **All** &gt; **MetricBase** &gt; **Trigger Flows.**.\n\n2.  Select **New Flow**.\n\n3.  Fill in the fields.\n\n<table id=\"choicetable_hsk_2zm_pgb\"><thead><tr><th align=\"left\" id=\"d465510e95\">\n\nField\n\n</th><th align=\"left\" id=\"d465510e98\">\n\nDescription\n\n</th></tr></thead><tbody><tr><td id=\"d465510e104\">\n\n**Flow name**\n\n</td><td>\n\nName of the flow to execute.\n\n</td></tr><tr><td id=\"d465510e113\">\n\n**Description**\n\n</td><td>\n\nExplanation of what the flow does and why you are associating this flow with the trigger.\n\n</td></tr><tr><td id=\"d465510e122\">\n\n**Application**\n\n</td><td>\n\nApplication scope to create your flow in. The value, **Global**, is the default.\n\n</td></tr><tr><td id=\"d465510e134\">\n\n**Protection**\n\n</td><td>\n\nOption to make the flow read-only. Selecting read-only prevents users who do not own the application scope from changing the flow. You can only select a value when you create the flow in an application scope you own.\n\n</td></tr><tr><td id=\"d465510e144\">\n\n**Run As**\n\n</td><td>\n\nChoose whether the flow runs as **System User** or **User who initiates the session** \\(the current user\\). For example, comments to incident records or approval emails should come from the current user making the comment or approval. Flows run by the initiating user respect settings that are user-specific like date/time format. The **Run As** setting does not apply to child subflows.\n\n**Note:** If you select **User who initiates the session**, ensure that security restrictions \\(ACLs\\) do not prevent the users who trigger the flow from performing the flow actions.\n\n</td></tr><tr><td id=\"d465510e170\">\n\n**Run with roles**\n\n</td><td>\n\nSelect the roles can run the flow. This option is only available when **Run as** is set to **user who initiates the session**.\n\n</td></tr></tbody>\n</table>4.  Select **Submit**.\n\n5.  Select **Add a trigger** to specify the trigger that kicks off this flow.\n\n6.  In the dialog box that appears, scroll, and select MetricBase for the trigger type.\n\n7.  Under **TRIGGER**, fill in the form to define the trigger to associate with this flow.\n\n    1.  In the **MetricBase Trigger** list, select a trigger by either selecting the magnifying glass to select an existing trigger or selecting the plus sign \\(+\\) to define a new trigger.\n\n    2.  Add requirements for the flow to execute by adding filter conditions.\n\n    3.  Beside **Condition Script**, select the magnifying glass to select a Condition Script or click the plus \\(+\\) to create a script.\n\n        Condition scripts add additional requirements for a trigger to execute a flow.\n\n    \\[Omitted image \"condition-script-flow-designer.png\"\\] Alt text: Condition script in Workflow Studio.\n\n8.  Under **ACTIONS**, select **Click to add an Action, Flow Logic, or Subflow**\n\n    1.  When selecting an action, select an action category in the first column of the dialog box, and a flow action in the second column.\n\n    2.  Create combinations of different actions, flow logics, and subflows to get the desired behavior.\n\n    3.  Select **Done** to complete each part of the flow action.\n\n    \\[Omitted image \"flow-action.png\"\\] Alt text: Selecting a flow.\n\n9.  Select **Save**.\n\n10. Test the flow.\n\n    1.  In the flow tab in Workflow Studio, select **Test**.\n\n    2.  Select the trigger **Level** to test, provide the **time of metric event**, and what **record** is triggering.\n\n        Different triggers may execute different flows. \\[Omitted image \"test-flow.png\"\\] Alt text: Test the flow.\n\n        **Note:** When you test a flow, the system does not execute the trigger, and therefore does not create a record. By selecting a record in the Test flow dialog box, the system acts as if that record was just created. For more information, see [Test a flow](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/build-workflows/flow-test.md).\n\n    3.  Select **Submit**.\n\n        The test completes. Select the message to view the flow execution details. Edit the settings if necessary, save again, and then retest.\n\n11. Select **Activate** to activate the trigger.\n\n    The flow does not execute unless you activate it.\n\n\n"}}