Skip to content

Workflow Management in ServiceNow MCP

This document provides detailed information about the workflow management tools available in the ServiceNow MCP server.

Overview

ServiceNow workflows are a powerful automation feature that allows you to define and automate business processes. The workflow management tools in the ServiceNow MCP server enable you to view, create, and modify workflows in your ServiceNow instance.

Available Tools

Viewing Workflows

  1. list_workflows - List workflows from ServiceNow
  2. Parameters:

    • limit (optional): Maximum number of records to return (default: 10)
    • offset (optional): Offset to start from (default: 0)
    • active (optional): Filter by active status (true/false)
    • name (optional): Filter by name (contains)
    • query (optional): Additional query string
  3. get_workflow_details - Get detailed information about a specific workflow

  4. Parameters:

    • workflow_id (required): Workflow ID or sys_id
  5. list_workflow_versions - List all versions of a specific workflow

  6. Parameters:

    • workflow_id (required): Workflow ID or sys_id
    • limit (optional): Maximum number of records to return (default: 10)
    • offset (optional): Offset to start from (default: 0)
  7. get_workflow_activities - Get all activities in a workflow

  8. Parameters:
    • workflow_id (required): Workflow ID or sys_id
    • version (optional): Specific version to get activities for (if not provided, the latest published version will be used)

Modifying Workflows

  1. create_workflow - Create a new workflow in ServiceNow
  2. Parameters:

    • name (required): Name of the workflow
    • description (optional): Description of the workflow
    • table (optional): Table the workflow applies to
    • active (optional): Whether the workflow is active (default: true)
    • attributes (optional): Additional attributes for the workflow
  3. update_workflow - Update an existing workflow

  4. Parameters:

    • workflow_id (required): Workflow ID or sys_id
    • name (optional): Name of the workflow
    • description (optional): Description of the workflow
    • table (optional): Table the workflow applies to
    • active (optional): Whether the workflow is active
    • attributes (optional): Additional attributes for the workflow
  5. activate_workflow - Activate a workflow

  6. Parameters:

    • workflow_id (required): Workflow ID or sys_id
  7. deactivate_workflow - Deactivate a workflow

  8. Parameters:
    • workflow_id (required): Workflow ID or sys_id

Managing Workflow Activities

  1. add_workflow_activity - Add a new activity to a workflow
  2. Parameters:

    • workflow_id (required): Workflow ID or sys_id
    • name (required): Name of the activity
    • description (optional): Description of the activity
    • activity_type (required): Type of activity (e.g., 'approval', 'task', 'notification')
    • attributes (optional): Additional attributes for the activity
    • position (optional): Position in the workflow (if not provided, the activity will be added at the end)
  3. update_workflow_activity - Update an existing activity in a workflow

    • Parameters:
    • activity_id (required): Activity ID or sys_id
    • name (optional): Name of the activity
    • description (optional): Description of the activity
    • attributes (optional): Additional attributes for the activity
  4. delete_workflow_activity - Delete an activity from a workflow

    • Parameters:
    • activity_id (required): Activity ID or sys_id
  5. reorder_workflow_activities - Change the order of activities in a workflow

    • Parameters:
    • workflow_id (required): Workflow ID or sys_id
    • activity_ids (required): List of activity IDs in the desired order

Usage Examples

Viewing Workflows

List all active workflows

result = list_workflows({
    "active": True,
    "limit": 20
})

Get details about a specific workflow

result = get_workflow_details({
    "workflow_id": "2bda7cda87a9c150e0b0df23cebb3590"
})

List all versions of a workflow

result = list_workflow_versions({
    "workflow_id": "2bda7cda87a9c150e0b0df23cebb3590"
})

Get all activities in a workflow

result = get_workflow_activities({
    "workflow_id": "2bda7cda87a9c150e0b0df23cebb3590"
})

Modifying Workflows

Create a new workflow

result = create_workflow({
    "name": "Software License Request",
    "description": "Workflow for handling software license requests",
    "table": "sc_request"
})

Update an existing workflow

result = update_workflow({
    "workflow_id": "2bda7cda87a9c150e0b0df23cebb3590",
    "description": "Updated workflow description",
    "active": True
})

Activate a workflow

result = activate_workflow({
    "workflow_id": "2bda7cda87a9c150e0b0df23cebb3590"
})

Deactivate a workflow

result = deactivate_workflow({
    "workflow_id": "2bda7cda87a9c150e0b0df23cebb3590"
})

Managing Workflow Activities

Add a new activity to a workflow

result = add_workflow_activity({
    "workflow_id": "2bda7cda87a9c150e0b0df23cebb3590",
    "name": "Manager Approval",
    "description": "Approval step for the manager",
    "activity_type": "approval"
})

Update an existing activity

result = update_workflow_activity({
    "activity_id": "3cda7cda87a9c150e0b0df23cebb3591",
    "name": "Updated Activity Name",
    "description": "Updated activity description"
})

Delete an activity

result = delete_workflow_activity({
    "activity_id": "3cda7cda87a9c150e0b0df23cebb3591"
})

Reorder activities in a workflow

result = reorder_workflow_activities({
    "workflow_id": "2bda7cda87a9c150e0b0df23cebb3590",
    "activity_ids": [
        "3cda7cda87a9c150e0b0df23cebb3591",
        "4cda7cda87a9c150e0b0df23cebb3592",
        "5cda7cda87a9c150e0b0df23cebb3593"
    ]
})

Common Activity Types

ServiceNow provides several activity types that can be used when adding activities to a workflow:

  1. approval - An approval activity that requires user action
  2. task - A task that needs to be completed
  3. notification - Sends a notification to users
  4. timer - Waits for a specified amount of time
  5. condition - Evaluates a condition and branches the workflow
  6. script - Executes a script
  7. wait_for_condition - Waits until a condition is met
  8. end - Ends the workflow

Best Practices

  1. Version Control: Always create a new version of a workflow before making significant changes.
  2. Testing: Test workflows in a non-production environment before deploying to production.
  3. Documentation: Document the purpose and behavior of each workflow and activity.
  4. Error Handling: Include error handling in your workflows to handle unexpected situations.
  5. Notifications: Use notification activities to keep stakeholders informed about the workflow progress.

Troubleshooting

Common Issues

  1. Error: "No published versions found for this workflow"
  2. This error occurs when trying to get activities for a workflow that has no published versions.
  3. Solution: Publish a version of the workflow before trying to get its activities.

  4. Error: "Activity type is required"

  5. This error occurs when trying to add an activity without specifying its type.
  6. Solution: Provide a valid activity type when adding an activity.

  7. Error: "Cannot modify a published workflow version"

  8. This error occurs when trying to modify a published workflow version.
  9. Solution: Create a new draft version of the workflow before making changes.

  10. Error: "Workflow ID is required"

  11. This error occurs when not providing a workflow ID for operations that require it.
  12. Solution: Make sure to include the workflow ID in your request.

Additional Resources