ServiceNow: Incident

ServiceNow: Incident

Disclaimer

Your use of this download is governed by Stonebranch’s Terms of Use.

Version Information

Template Name

Extension Name

Version

Status

Template Name

Extension Name

Version

Status

ServiceNow Incident

ue-servicenow-incident

3 (Current 3.0.0)

Fixes and new Features are introduced.

This is a major release and introduces breaking changes that might affect some customers depending on their setup. Administrators are strongly advised to refer to Changelog for more information on the changes introduced in this release.

Refer to Changelog for version history information.

Overview

ServiceNow aims to deliver digital workflows that create great experiences and unlock productivity for enterprise operations. The company's core business revolves around management of "incident, problem, and change".

This Integration allows customers to create incident tickets in ServiceNow straight from the Universal Controller. A typical Use Case is creating a ticket in ServiceNow in the event of a Task failure within the Universal Controller.

Key Features

Feature

Description

Feature

Description

Actions

Create a ServiceNow Incident.

Authentication

  • Authentication using ServiceNow Credentials.

  • Authentication using OAuth2.

Input/Output

  • Capability to send the output of any task instance as an incident attachment.

  • Capability to include some of the available instance fields as part of the incident attachment.

Requirements

This integration requires a Universal Agent and a Python runtime to execute the Universal Task.

Area

Details

Area

Details

Python Version

Requires Python 3.11, tested with Agent bundled python distribution

Universal Agent Compatibility

  • Compatible with Universal Agent for Windows x64 and version >= 7.6.0.0.

  • Compatible with Universal Agent for Linux and version >= 7.6.0.0.

Universal Controller Compatibility

Universal Controller Version >= 7.6.0.0.

Network and Connectivity

  • Extension's Universal Agent host should be able to reach ServiceNow REST endpoints.

  • When creating attachments from Task Instances, the extension's Universal Agent Host should be able to reach the Universal Controller.

  • The ServiceNow Credentials provided in the ServiceNow Incident Universal Task should have sufficient permissions to invoke ServiceNow APIs and create incidents.

Supported ServiceNow Versions

This integration is tested on ServiceNow Vancouver. It should be compatible with newer versions of ServiceNow as long as ServiceNow backward compatibility is preserved.

Configuration Examples

Example: Create Incident

Example of creation of an incident.

Example: Create an Incident with an attachment from a Sibling Task

Example of creating an incident with an attachment from a sibling task within a workflow. The workflow is configured to create a ServiceNow incident when a task fails.

An example workflow where a ServiceNow Incident Universal Task follows the Failure transition of a SQL Task is provided below.


An example of a task configured to use the information from the failed Universal Task Instance as an attachment for creating a ServiceNow Incident is provided below.

Example: Create an Incident from any Task Instance

Example of creation of an incident from any Task Instance.

 

Best practice to configure such a scenario within UAC is shown below.

Step 1: Create a Monitor Task that monitors for the failure of tasks by configuring Monitor Details.

Step 2: Configure the ServiceNow Incident task. The created Incident Task propagates the output of the failed Task Instance as an attachment to ServiceNow. For that, a Task Monitor trigger is required.

Step 3: Create a Task Monitor Trigger linked to the Monitor Task (on Step 1), which controls the action that needs to be taken when the monitor successfully monitors a failure, in this case, the trigger of an incident ticket configured on Step 2.

Example: Create Incident using OAuth2 authentication

Example: Create Incident with Additional Fields

Input Fields

The input fields for this Universal Extension are described below.

Name

Type

Description

Version Information

Name

Type

Description

Version Information

Action

Choice

Action performed upon the task execution. Available actions.

  • Create Incident (default)

Introduced in 1.0.0

ServiceNow Instance URL

Text

URL of the ServiceNow instance.

Introduced in 1.0.0

Authentication Type

Choice

Authentication method to use. Available methods,

  • Basic Authentication (default)

  • Oauth2 (ServiceNow API endpoint)

Introduced in 1.0.0. Modified in 2.1.0

ServiceNow Credentials

Credentials

Credentials for accessing ServiceNow via API. The Credentials definition should be as follows.

  • ServiceNow username as "Runtime User".

  • ServiceNow password as "Runtime Password".

Introduced in 1.0.0

Client Credentials

Credentials

Credentials for authenticating using OAuth2 (retrieving access token). The Credentials definition should be as follows.

  • Client ID as "Runtime User"

  • Client Secret as "Runtime Password"

Required when Authentication Type is “Oauth2 (ServiceNow API)”.

Introduced in 2.1.0

Caller

Dynamic Choice

User who reported or is affected by this incident.

Introduced in 1.0.0

Category

Dynamic Choice

The category for incident creation. If not provided, the default category defined on ServiceNow will be considered.

Introduced in 1.0.0

Subcategory

Dynamic Choice

The subcategory for incident creation. The choice of Subcategory depends on the previous choice of Category.

Introduced in 1.0.0

Impact

Dynamic Choice

The impact of the created incident.

Introduced in 1.0.0

Urgency

Dynamic Choice

The urgency of the created incident.

Introduced in 1.0.0

Assigned To

Dynamic Choice

The user is primarily responsible for treating this incident in ServiceNow.

Introduced in 1.0.0

Assignment Group

Dynamic Choice

Assignment group that is responsible for working on this incident in ServiceNow.

Introduced in 1.0.0

Short Description

Text

Short description of the incident.

Introduced in 1.0.0

Description

Large Text

Description of the incident.

Introduced in 1.0.0

Provide Additional Fields

Choice

The Provide Additional Fields provided as Choice field. This field allows the user to choose whether to include or not additional ServiceNow fields in the request as a JSON formatted text. The following options are available.

  • -- None -- (default)

  • As JSON Text

Introduced in 2.2.0

Additional Fields (JSON)

Large Text

Additional Fields (JSON) provided as JSON formatted text. Each additional field can be sent as a key/value pair. The key corresponds to the column name of the incident entry, as defined in the incident table's configuration. The value is set according to the entry's type. For more information, refer to Additional Fields (JSON) Configuration.

Required when Provide Additional Fields is "As JSON Text".

If a ServiceNow Field is defined in Additional Fields (JSON), and at the same time it is defined with a value on another existing field, the value defined on the specific designated field has precedence and the one defined on Additional Fields (JSON) will be ignored.

Introduced in 2.2.0

Attach Instance Information

Choice

Parameter controlling whether an attachment will be attached to the incident and the source of it. The following options are available.

  • -- None -- (default)

  • Sibling Task Instance

  • Any Task Instance

Introduced in 1.0.0. Modified in 2.3.0

Task Instance ID

Text

UUID of the task instance, the output of which is attached. UAC Functions can be used to resolve the required Task Instance ID. For more information, the reader can refer to the task examples.

Required when Attach Output Source is “Sibling Task” or “Any Task Instance”.

Introduced in 1.0.0

Instance Output Type

Choice

The type of output to be used as an attachment. The following options are available.

  • -- None --

  • All - all available task outputs related to the task instance will be attached

  • Standard Output

  • Standard Error

Required when Attach Output Source is “Sibling Task” or “Any Task Instance”.

The full content of the outputs selected will be retrieved with the exception of STDOUT/STDERR which is controlled by field Number of lines for STDERR/STDOUT.

Introduced in 1.0.0

Number of lines for STDERR/STDOUT

Integer

The number of lines to be retrieved from the task instance output. The extension will provide up to the specified number of lines, or less if there are not enough lines generated.

Required when Instance Output Type is “All”, “Standard Output” or ”Standard Error”.

Default value is 100.

The value must be greater than 0.

Introduced in 1.0.0

Instance Fields

Multiple Choice

The instance fields to be retrieved related to the task instance. The following options are available.

  • Status Description

  • Exit Code

  • Execution User

  • Task Name

More than one options can be selected. Instance Field information appears at the top of the ServiceNow Incident Attachment. 

Not all task outputs provide error information, in such cases the Task Instance “Status Description” can provide more meaningful information to the ServiceNow Incident attachment.

Introduced in 1.0.0

UC URL

Text

Base URL of the target Universal Controller.

Required when Attach Output Source is “Sibling Task” or “Any Task Instance”.

This Field and UC Credential is necessary for the task instance information to be retrieved and used to create the ServiceNow Incident attachment.

Introduced in 1.0.0

UC Credentials

Credentials

Credential for accessing the Controller.

The Credentials definition should be as follows.

  • UA Controller username as "Runtime User".

  • UA Controller password as "Runtime Password".

Required when Attach Output Source is “Sibling Task” or “Any Task Instance”.

This Field and UC URL is necessary for the task instance information to be retrieved and used to create the ServiceNow Incident attachment.

Introduced in 1.0.0

Using empty values for dynamic choice fields will result in ServiceNow setting a default value for the field if one exists.

Using non-existing values for dynamic choice fields will result in ServiceNow setting an empty value or a default value for the field if one exists.

Additional Fields (JSON) Configuration

The Additional Fields (JSON) field allows users to set values for existing ServiceNow Fields in JSON format. 

Each key in the JSON represents a column name in the Incident table. To find the correct column names, follow these steps.

  • On ServiceNow platform, at the top menu click on All.

  • Search for System Definition. Under System Definition select Tables.

  • At the top, search for the table by entering the Table Name, which in this case it is Incident.

  • Select the Incident table. A list with all the Incident table fields will appear.

  • Hover on the specific field and click on the Info Icon.

  • New small window will appear in which the Column name can be seen.

Example of how locating the Column name of a field looks like can be seen below.

The value for each field must be formatted according to the corresponding incident table field type and should comply with ServiceNow API requirements. Example of how the Additional Fields (JSON) field can be populated with various of table field types is shown below.

Configuring Additional Fields (JSON)

{ "active": true, "on_hold": false, "opened_at": "2024-08-26 15:30:00", "resolved_at": "2024-08-27 10:00:00", "impact": 3, "urgency": 2, "priority": 3, "state": 1, "short_description": "Printer not working", "description": "The office printer on the 3rd floor is not responding.", "contact_type": "phone", "category": "hardware", "number": "INC001000", "reassignment_count": 1, "caller_id": "Lucius Bagnoli", "assigned_to": "Jimmie Barninger", "watch_list": "Lucius Bagnoli,Jimmie Barninger", "work_notes": "Checked printer connection. Power seems to be the issue.", "comments": "User reported loud noise before printer stopped working." }

The following table provides more information on the example's fields.

ServiceNow Field Type

Example field

ServiceNow Field Type

Example field

Boolean

active, on_hold

Date/Time

opened_at, resolved_at

Integer

impact, urgency, priority, reassignment_ count

String

short_description, description, contact_type, category, number

Reference

caller_id, assigned_to

List

watch_list

Journal Input

work_notes, comments

Task Output

Exit Codes

The exit codes for this Universal Extension are described below.

Exit Code

Status Classification Code

Status Classification Description

Status Description

Exit Code

Status Classification Code

Status Classification Description

Status Description

0

SUCCESS

Successful Execution

SUCCESS: Ticket Created

1

FAIL

Client Error. The error originated on the client side.

FAIL: Client Error: < Error description >

1

FAIL

Server Error. The error originated from the server side.

FAIL: Server Error: < Error description >

2

AUTHENTICATION_ERROR

Bad Credentials

AUTHENTICATION_ERROR: The account cannot be authenticated.

3

AUTHORIZATION_ERROR

Insufficient permissions

AUTHORIZATION_ERROR: The account is not authorized to perform the requested action.

20

DATA_VALIDATION_ERROR

Input fields validation error.

DATA_VALIDATION_ERROR: Some of the input fields cannot be validated. See STDERR for more details.

Extension Output

In the context of a workflow, subsequent tasks can rely on the information provided by this integration as Extension Output.

Attribute changed is populated as follows

  • true, in case a ServiceNow incident is successfully created.

  • false, in case a ServiceNow incident is not successfully created.

The Extension output contains the attribute result. Attribute result contains the following sub-attributes:

Attribute

Type

Description

Attribute

Type

Description

code

number

The HTTP Response Code from ServiceNow.

ticket_number

string

The ticket number is given to the created incident.

sys_id

string

The UID of the incident, generated by ServiceNow.

An example of the Extension Output for creating a ServiceNow Incident is given below.

Extension Output
{ "exit_code": 0, "status_description": "SUCCESS: ServiceNow Incident Create Incident executed successfully!", "changed": true, "invocation": { "extension": "ue-servicenow-incident", "version": "2.3.3", "fields": {...}, "result": { "code": 201, "ticket_number": "INC0010056", "sys_id": "5115d027a30f383f6df5209c5e27a117" } }

 

STDOUT and STDERR

STDOUT and STDERR provide additional information to the User. The populated content can be changed in future versions of this extension without notice. Backward compatibility is not guaranteed.

How To

Import Universal Template

To use the Universal Template, you first must perform the following steps.

  1. This Universal Task requires the Resolvable Credentials feature. Check that the Resolvable Credentials Permitted system property has been set to true.

  2. Import the Universal Template into your Controller:

    1. Extract the zip file, you downloaded from the Integration Hub.

    2. In the Controller UI, select Services > Import Integration Template option.

    3. Browse to the “export” folder under the extracted files for the ZIP file (Name of the file will be unv_tmplt_*.zip) and click Import.

    4. When the file is imported successfully, refresh the Universal Templates list; the Universal Template will appear on the list.

Modifications of this integration, applied by users or customers, before or after import, might affect the supportability of this integration. For more information refer to Integration Modifications.

Integration Modifications

Modifications applied by users or customers, before or after import, might affect the supportability of this integration. The following modifications are discouraged to retain the support level as applied for this integration.

  • Python code modifications should not be done.

  • Template Modifications

    • General Section

      • "Name", "Extension", "Variable Prefix", and "Icon" should not be changed.

    • Universal Template Details Section

      • "Template Type", "Agent Type", "Send Extension Variables", and "Always Cancel on Force Finish" should not be changed.