{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":3970,"path":"build-workflows/workflow-studio/build-your-first-flow.md","title":"Build your first flow in Workflow Studio","bundle":null,"doc_type":null,"release":"australia","body":"\n# Build your first flow in Workflow Studio\n\nStep through an example of how to build, test, and activate a sample flow in Workflow Studio.\n\n## Before you begin\n\n-   Role required: admin, flow\\_designer, or delegated\\_developer\n-   Make sure to Familiarize yourself with any features that your business uses to automate operations on the ServiceNow AI Platform, such as [flows](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/exploring-flows.md), [subflows](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/exploring-subflows.md), and [actions](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/exploring-actions.md).\n\n## About this task\n\nTo help you get started with building your first flow in Workflow Studio, follow along with the steps below. The example flow will start, or trigger, every time a user on the instance creates a request for a Service Catalog item. When a request is created, our flow will automatically run the following actions:\n\n-   Check if the catalog item's price is greater than $1,000.\n-   If the price is greater than $1,000, notify the requester's manager to approve the request.\n-   Otherwise, if the price is less than or equal to $1,000, automatically approve and close the request.\n\n## Procedure\n\n1.  Use the filter navigator to go to **All** &gt; **Self-Service** &gt; **Service Catalog**.\n\n2.  From the Top requests box, select **Standard Laptop** and complete the record producer.\n\n    The system produces a Requested Item record that has a price of $1100 or more \\(RITM0010001\\).\n\n3.  Use the filter navigator to go to **All** &gt; **Process Automation** &gt; **Flow Designer**.\n\n4.  On the Workflow Studio landing page's main header, select **New** &gt; **Flow**.\n\n5.  In the Flow properties window, fill in the following fields:\n\n    |Field|Action|\n    |-----|------|\n    |Flow name|Enter `Approval flow for requested items`|\n\n    Then select **Submit** to open your flow in the Workflow Studio design environment.\n\n6.  Under the TRIGGER section, select **Add a trigger**.\n\n7.  In the trigger picker, either enter `Service Catalog` in the search field, or locate the **Service Catalog** trigger under the APPLICATION category.\n\n    Then, select the **Service Catalog** trigger to add this trigger to your flow. Later, when we test this flow, we can simulate firing this trigger by creating a new Service Catalog Item Request record.\n\n8.  Click **Done** to finish adding the **Service Catalog** trigger to your flow.\n\n9.  Under the ACTIONS section, select **Add an Action, Flow Logic, or Subflow**.\n\n    Then, select **Flow Logic** to open the flow logic picker.\n\n10. In the flow logic picker, select **If**\n\n11. Next to the Condition 1 input, click the pill picker icon \\(\\[Omitted image \"data\\_pill\\_picker.png\"\\] Alt text: Pill picker icon\\) to open the dot-walker.\n\n    The dot-walker lets you access data from the trigger in your flow. Later, when you add actions to your flow, you can also use the dot-walker to access data from those actions. You can use the dot-walker to drill down into data that references other records in order to get the proper field placeholder value that you want to drop as a data pill in an action's input.\n\n12. Navigate, or dot-walk, to **Trigger - Service Catalog** &gt; **Requested Item Record** &gt; **Price** and select **Price** to add this data pill to the Condition 1 input.\n\n13. In the condition builder's next field, choose **greater than**, and then enter `1000` in the final field.\n\n    Now, you've successfully set up a condition that will check if the price of the catalog item that a user requests is greater than $1,000.\n\n14. Click **Done** to finish adding the **If** flow logic to your flow.\n\n15. Under your **If** flow logic condition, select **Action**.\n\n16. In the action picker, either enter `Ask For Approval` in the search field, or locate the **Ask For Approval** action by selecting **ServiceNow Core** &gt; **Ask For Approval** under the Default subcategory.\n\n17. Add the following values for the Ask For Approval action's inputs:\n\n    |Input|Action|\n    |-----|------|\n    |Record|Click the pill picker icon \\(\\[Omitted image \"data\\_pill\\_picker.png\"\\] Alt text: Pill picker icon\\) to open the dot-walker. Then, navigate, or dot-walk, to **Trigger - Service Catalog** &gt; **Requested Item Record** and select **Requested Item Record** to add this data pill to the input.|\n    |Table|Leave as `Requested Item [sc_req_item]`.|\n    |Approval Field|Leave as `Approval`.|\n    |Journal Field|Leave as `Approval history`.|\n    |Rules|Leave the first field as `Approve`. Under When, select **Anyone approves** from the list. Then, click the pill picker icon \\(\\[Omitted image \"data\\_pill\\_picker.png\"\\] Alt text: Pill picker icon\\) to open to dot-walker. Navigate, or dot-walk, to **Trigger - Service Catalog** &gt; **Requested Item Record** &gt; **Opened by** &gt; **Manager** and select **Manager** to add this data pill to the field.|\n    |Due Date|Leave as `None`.|\n\n    Now, you've successfully set up a conditional action that will automatically ask for approval from the requester's manager for any catalog item they request that has a price greater than $1,000.\n\n18. Click **Done** to finish adding the conditional **Ask for Approval** action within the **If** flow logic of your flow.\n\n19. Select **Add an Action, Flow Logic, or Subflow**.\n\n    Then, select **Flow Logic** and choose **Else** from the flow logic picker.\n\n20. Under your **Else** flow logic, select the plus icon \\(\\[Omitted image \"add-action-icon.png\"\\] Alt text: Plus icon.\\) and then select **Action**.\n\n    From the action picker, select the **Update Record** action.\n\n21. Add the following values for the Update Record action's inputs:\n\n    |Input|Action|\n    |-----|------|\n    |Record|Click the pill picker icon \\(\\[Omitted image \"data\\_pill\\_picker.png\"\\] Alt text: Pill picker icon.\\) to open the dot-walker. Then, navigate, or dot-walk, to **Trigger - Service Catalog** &gt; **Requested Item Record** and select **Requested Item Record** to add this data pill to the input.|\n    |Table|Leave as `Requested Item [sc_req_item]`.|\n    |Fields|Select **+ Add field value**. Then, select the **Approval** field and choose **Approved** as the field's value. Next, select the **State** field and choose **Closed Complete** as the field's value. Finally, select the **Close notes** field and enter `Request automatically approved, as requested item's value is less than $1,000` for the field's value.|\n\n    Now, you've successfully set up a conditional action that automatically approves and closes the catalog item request if the requested item's price is less than or equal to $1,000.\n\n22. To finish adding the conditional **Update Record** action within the **Else** flow logic of your flow, click **Done**.\n\n23. In the main header, click **Save** to save the changes you've made to your flow.\n\n    Your flow should look similar to the following example:\n\n    \\[Omitted image \"build-your-first-flow-example.png\"\\] Alt text: An example flow that asks for a manager's approval for requested items whose price is greater than $1,000.\n\n24. To test your flow and see if it triggers and runs properly without any errors, go to the main header and click **Test**.\n\n25. In the Test Flow window, select a Requested Item record that has a price greater than $1000, then select **Run Test**.\n\n    For example, select the requested item record that you previously created from the service catalog \\(RITM0010001\\).\n\n    You can select the Create new record icon \\(\\[Omitted image \"add-record-button.png\"\\] Alt text: Create new record icon.\\) to create a new requested item.\n\n26. Select **Your test has finished running. View the flow execution details.**\n\n27. On the Execution Details page, see the values that populated for the trigger and each automated action in your flow.\n\n    For more information, see [Flow execution details](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/flow-execution-details.md).\n\n28. Navigate back to your flow.\n\n29. In the main header, click **Activate** so that your flow's trigger fires whenever a user on your instance creates a new Service Catalog Item Request record.\n\n\n## What to do next\n\nYour flow is now active and will run whenever it's triggered. Next, you can manage your flow every time it runs by viewing your flow's execution history. To view this history, open your flow in the Workflow Studio design environment and click **Executions** in the main header. The resulting page shows you the state of completion for each flow execution as well as how long it took for each flow execution to run, or its runtime. To troubleshoot a flow execution for errors, select an execution from this list to open the [Flow execution details](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/flow-execution-details.md).\n\n"}}