Thank you for your feedback.
Form temporarily unavailable. Please try again or contact docfeedback@servicenow.com to submit your comments.
Versions
  • London
  • Kingston
  • Jakarta
  • Istanbul
  • Helsinki
  • Geneva
  • Store
Close

Getting started with actions

Getting started with actions

Transform the Ask for Approval action into a reusable action that always requires manager approval.

Before you begin

Role required: admin
Note: While Action Designer is designed to use the action_designer and delegated_developer roles in most scenarios, this tutorial uses the admin role to illustrate functionality without requiring additional roles to set up records and approve requests.

Complete the steps in Getting started with flows. This tutorial replaces the Ask for Approval action in the Expense Approval flow.

About this task

Actions are made up of:
  • Inputs: Data variables used in your action.
  • Steps: Operations on the inputs or results from a prior step that generate data that can be used in later steps.
  • Outputs: Data variables that represent the results of the action. These results are available to other actions in a flow.

Unlike the core Ask for Approval action where flow designers must manually configure the approval rules, this custom action always uses the same approval rules when added to a flow. You might create a reusable action if your flow designers often use an action with the same configuration. For example, if your flow designers always use the request manager approval and due date options, this action automatically uses them and therefore requires less flow configuration.

Procedure

  1. Open the Expenses Getting Started application in Studio.
    Alternatively, you can navigate to Flow Designer > Designer and select New Action to access Action Designer in the platform. In the Action Properties, select your scoped application in the Application field.
  2. Create an action.
    1. Click Create Application File.
    2. Under Flow Designer, select Action and click Create.
    3. In the Name field, enter Ask for Manager Approval.
    4. In the Description field, enter Approve or reject a request based on manager approval or rejection. Allow manual approvers to be added.
    5. Click Submit.
      An Ask for Manager Approval action is created in the Expenses Getting Started scope.
  3. Define the inputs in the Ask for Manager Approval action.
    1. Select + Create Input and add the following values.
      • Name: Request
      • Type: Reference
      • Reference Table: Expenses [x_expenses_getting_expenses]

      Add a Request input to the action.

    This input enables you to reference any field or record from the Expenses table. Use the data pills on the right-hand side to add the record or its fields to action steps.
  4. Add an Ask for Approval step.
    1. Click the + underneath Inputs in the Action Outline.
    2. Select Ask for Approval.
    3. Complete the fields in the Ask for Approval step.
      • Record: Under the Input Variables category, drag the [Request] data pill from the right-hand pane.
      • Table: Set to Expenses [x_expenses_getting_expenses].
      • Approval Field: Set to Approval.
      • Journal Field: Set to Approval history.

      Add Ask for Approval step.

    4. Define rules in the Ask for Approval step. You can use the data pill picker, or drag the data pills from the right-hand pane to select the data you need.
      • [Approve] when [Anyone approves] from the field [action->Request->Requested for->Manager], [OR]
      • [Anyone approves] from the field [Manual User(s)].

      Select Add another OR rule set to define rejection rules:

      • [Reject] when [Anyone rejects] from the field [action->Request->Requested for->Manager], [OR]
      • [Anyone rejects] from the field [Manual User(s)].

      Add rules to the Ask for Approval step.

    5. Define a due date in the Ask for Approval step.
      • [Approve] if pending by [Relative date] [1][Days] from [action->Request->Created].
      • Days schedule [8-5 weekdays excluding holidays].

      This due date automatically approves all requests that have not been approved or denied within one day from when the request was created.

      Add a Due Date to the Ask for Approval step.

  5. Define the outputs in the Ask for Manager Approval action. Adding an output makes data available to a flow. For example, this action outputs the approval state of the record.
    1. Select + Create Outputs and add the following values.
      • Name: Approval state
      • Value: In the right-hand pane, expand the Ask for Approval step category and drag the [Approval State] data pill.

      Create outputs to the action.

    2. Click Save.
  6. Add a custom icon for your application that displays in Flow Designer. All actions in the application scope use the custom icon.
    1. In Studio, navigate to File > Settings.
      The application settings open.
    2. In the Logo field, select Click to add....
    3. Upload an icon to use with your reusable actions.
  7. Test the reusable action within your flow.
    1. Return to the Expense Approval flow.
    2. Remove the 2.1 Ask for Approval action from the flow. This action will be replaced by the reusable Ask for Manager Approval action.
    3. Set Show draft actions to true.
    4. Add the Ask for Manager Approval action to your flow.
    5. In the right-hand pane, expand the Trigger - Record Created category and drag the [Expenses Record] data pill into the Request [Expenses] field.
    Add the action to the flow and enter an input.
  8. Click Save.
  9. Test the flow using a record with an amount below the designated limit.
    1. From the flow, click Test.
      The Test flow modal appears.
    2. In the Record field, select a record you created in earlier steps that has value in the Amount field under the 100.00 limit. Verify that you have not already run tests using this record.
    3. Select Run Test.
    4. After the flow executes, click Flow has been executed. To view the flow, click here.
      The Execution Details open.
    Because the amount is less than 100.00, the first condition is met and the request is approved. The Else condition is not evaluated.

    Test result for first condition evaluated.

  10. Test a record with an amount over the designated limit. Verify that you have not already run a test on the test record.
    Because the amount is over the designated limit, the second condition is evaluated.

    Test result for second condition evaluated.

  11. Approve the request.
    1. Navigate to the test record and change the value of the State field in the Approvers related list to Approved.
    2. Navigate back to the flow execution details and refresh the browser.
      Because the request is approved, the flow completes.

      Execution details showing a completed approval.

  12. Navigate to the Ask for Manager Approval action and click Publish. Publishing an action enables you to activate any flow that uses it.
  13. Navigate to the flow and set Show draft actions to false.
  14. Click Activate. Activating a flow sets it to run every time the trigger conditions are met.

Result

The Expense Approval flow runs every time a record is created in the Expenses table. Now that the flow is activated and working as expected, you can publish it to the application repository and deploy it to other instances.