Skip to Content
Knowledge is Power, so learn 🎉
Tutorial13 03 2025ServiceNow Workflow Wizardry: Craft Powerful Approvals Like a Pro (Step-by-Step)!

ServiceNow Workflow Wizardry: Craft Powerful Approvals Like a Pro (Step-by-Step)!

Welcome to the exciting world of ServiceNow Workflow approvals! Approvals are the backbone of many automated processes in ServiceNow, ensuring that requests, changes, and other actions receive the necessary authorization before proceeding. This guide will walk you through the fundamentals of creating and configuring approvals in ServiceNow Workflows, turning you from a newbie into a workflow wizard.

What are ServiceNow Workflows and Approvals?

Before we dive in, let’s define our terms:

  • Workflow: An automated, multi-step process that orchestrates tasks and actions within ServiceNow. It’s the engine that drives automation.
  • Approval: A formal process that requires one or more users or groups to approve or reject a request before it can move forward in a workflow.

Approvals are crucial for maintaining compliance, managing risk, and ensuring accountability within your organization.

Setting the Stage: Accessing the Workflow Editor

First, you’ll need access to the Workflow Editor. Typically, the workflow_admin role is required. Here’s how to get there:

  1. Navigate: In the Application Navigator (left-hand side of the ServiceNow interface), type “Workflow Editor”.
  2. Open: Click on the “Workflow Editor” module.

You’ll be greeted with the Workflow Editor interface, which might seem daunting at first, but fear not! We’ll break it down.

Creating Your First Workflow

Let’s create a simple workflow to approve a change request.

  1. New Workflow: In the Workflow Editor, click “New Workflow”.
  2. Table: Choose the table your workflow will apply to. In this case, select “Change Request [change_request]”.
  3. Name: Give your workflow a descriptive name, like “Change Request Approval Workflow”.
  4. Description: (Optional) Provide a brief description of what the workflow does.
  5. If condition matches: Choose your trigger condition. For this example, select “always”.
  6. Submit: Click “Submit”.

Now you have a blank workflow canvas!

Adding the Approval Activity

The core of our workflow is the Approval activity. Here’s how to add it:

  1. Locate: In the left-hand pane, under “Core Activities”, find the “Approval - User” activity.
  2. Drag and Drop: Drag the “Approval - User” activity onto the workflow canvas, positioning it between the “Begin” and “End” activities.

Configuring the Approval - User Activity

Now comes the crucial part: configuring the approval activity. Double-click on the “Approval - User” activity to open its properties.

Let’s go through the key fields:

  • Name: Give the activity a meaningful name, such as “Manager Approval”.
  • Users: Specify the users who need to approve the request. You can choose:
    • Specific Users: Manually select users from a list. Not ideal for scalability.
    • Script: Use a script to dynamically determine the approvers. This is more powerful and flexible.
    • Group: Select a group. Any member of the group can approve.
    • Approval Rule: Use pre-defined approval rules for more complex scenarios.
  • Roles: Similar to group but based on Roles.
  • Source Type: Defines what table to evaluate when trying to match a user or group.
  • Wait for: Defines if the workflow waits for everyone to approve or just one approval.
  • Condition: An optional condition that determines whether the approval activity should even run.

Example: Approving to the Change Request’s Assigned To Manager

Let’s configure the workflow to route the approval to the manager of the user assigned to the change request. We’ll use a script for this:

  1. In the “Users” field, select “Script”.
  2. A script editor will appear. Enter the following script:
(function(current, approvers, step, context) { // Get the assigned to user. var assignedTo = current.assigned_to; // Check if assigned to user exists. if (assignedTo) { // Query the user record to get the manager. var user = new GlideRecord('sys_user'); if (user.get(assignedTo)) { //Check if the User Record has a manager if (user.manager != ''){ approvers.push(user.manager); // Add the manager to the approvers list. } else { gs.log("No manager found for " + user.name); } } } else { gs.log("No Assigned To User found"); } })(current, approvers, step, context);

Explanation of the script:

  • (function(current, approvers, step, context) { ... }) This is the standard format for workflow script includes.
  • current represents the current change request record.
  • approvers is an array where you add the users or groups that need to approve.
  • current.assigned_to accesses the “Assigned to” field on the change request.
  • GlideRecord('sys_user') creates a GlideRecord object to query the User table.
  • user.get(assignedTo) retrieves the user record based on the assigned to user’s sys_id.
  • approvers.push(user.manager) adds the manager’s sys_id to the approvers array.
  • gs.log writes to the system logs (helpful for debugging).
  1. Click “Submit” to save the activity properties.

Handling Approval Outcomes

Now, we need to handle what happens after the approval activity. Typically, you’ll have two paths: one for approved and one for rejected.

  1. Transitions: Click the small dot on the right side of the “Manager Approval” activity. Drag a connector to the “End” activity. This creates a transition. ServiceNow automatically creates a second transition by default.
  2. Approval - Actioned condition: Right-click on the first transition that you created, select Properties.
  3. Condition: On the transition properties, set the condition to answer == 'approved'
  4. Approval - Rejected condition: Right-click on the other transition that was created, select Properties.
  5. Condition: On the transition properties, set the condition to answer == 'rejected'

Now, based on the approval outcome, the workflow will follow different paths. You can add additional activities (e.g., notifications, task creation) to each path as needed.

Example: Sending Notifications on Approval/Rejection

  • Approved Path: Drag a “Send Notification” activity to the approved path. Configure it to send a notification to the change request’s requested by user, informing them that their request has been approved. Include relevant information like the change request number and the approver’s name.
  • Rejected Path: Drag a “Send Notification” activity to the rejected path. Configure it to send a notification to the change request’s requested by user, informing them that their request has been rejected, and provide a reason for the rejection (ideally, the approver would have added a comment explaining their decision).

Publishing Your Workflow

Once you’re satisfied with your workflow, it’s time to publish it.

  1. Publish: In the Workflow Editor, click the “Publish” button in the top right corner.

Your workflow is now active and will run whenever a new change request is created.

Testing and Debugging

Testing is crucial. Create a new change request and trigger the workflow. Monitor the workflow execution using the Workflow Context to see if the approval is routed correctly and the notifications are sent as expected. The workflow context can be found by opening the Change Request and clicking the “Show Workflow” related link at the bottom. It is highly recommended to use gs.log messages liberally throughout your scripts to help debug. These will be output to the system logs.

Advanced Approval Techniques

Once you’ve mastered the basics, explore these advanced techniques:

  • Approval Chains: Create workflows with multiple approval stages, where one approval triggers another.
  • Dynamic Approvers: Use scripts to dynamically determine approvers based on complex business rules. For example, you might route approvals based on the change request’s risk level or impact.
  • Approval Rules: Leverage approval rules for more complex scenarios, such as approvals based on price thresholds or specific item categories.
  • Delegation: Allow users to delegate their approvals to other users.
  • Rejection Handling: Implement robust rejection handling, including sending notifications, creating tasks, and providing options for the requestor to modify and resubmit their request.

Best Practices

  • Name Activities Clearly: Use descriptive names for all activities in your workflow.
  • Add Comments: Add comments to your scripts to explain the logic.
  • Use Logging: Use gs.log statements to track workflow execution and debug issues.
  • Keep Workflows Simple: Break down complex processes into smaller, more manageable workflows.
  • Test Thoroughly: Test your workflows thoroughly before deploying them to production.

Conclusion

Congratulations! You’ve taken your first steps towards becoming a ServiceNow workflow wizard. By understanding the basics of workflow creation, approval activity configuration, and handling approval outcomes, you can automate critical processes and improve efficiency within your organization. Remember to practice, experiment, and explore the advanced techniques to unlock the full potential of ServiceNow workflows. Keep building, testing, and iterating, and you’ll be crafting powerful approvals like a pro in no time!

Last updated on