> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/create-service-now-tickets-in-cd-stages.md).

# Create ServiceNow tickets in CD stages

Create ServiceNow tickets in CD stages.

This topic describes how to create ServiceNow tickets in Harness Deploy and Approval stages.

Harness enables you to create and manage ServiceNow change requests, incident tickets, change tasks, and problem-type tickets from your pipeline step using the **ServiceNow Create** step.

You can add the Create ServiceNow step to a Harness Deploy stage or an Approval stage and do the following:

* Automatically create change requests in ServiceNow to track updates to your build, test, and production environments by adding a **ServiceNow Create** step in your pipeline.
* Automatically create and assign ServiceNow tickets to triage and resolve incidents quickly in the event of pipeline failures.

***

## What you will learn from this topic

* How to [add a ServiceNow Create step](#add-a-servicenow-create-step) to a stage and [configure fields](#configure-fields).
* How to create a ticket [from a form template](#create-from-form-template) or [from a standard template](#create-from-standard-template).
* How to create [normal, standard, or emergency change requests](#normal-and-standard-change-requests).
* How to use [custom tables](#custom-table-support), including [with the template flow](#use-custom-tables-with-the-template-flow).

***

## Before you begin

The following prerequisites and considerations apply to the ServiceNow Create step:

* **ServiceNow connector**: Add a Harness ServiceNow connector before or during the Create ServiceNow step setup. Go to [Connect to ServiceNow](https://developer.harness.io/docs/platform/connectors/ticketing-systems/connect-to-service-now) to create one.
* **ServiceNow roles**: You need the `itil` role for end-to-end integration with Harness.

{% hint style="warning" %}
**Each run creates a new ticket**

When you use a ServiceNow Create step, it creates a new, independent ServiceNow ticket each time it runs (rather than updating the same issue). Add ServiceNow Create to a stage only if you want to create a new ServiceNow ticket on every run of the stage.
{% endhint %}

{% hint style="info" %}
**Using templates**

* You must install the Integration for Harness Software Delivery Platform app in your ServiceNow instance from the [ServiceNow store](https://store.servicenow.com/sn_appstore_store.do#!/store/application/de154a1e1b75851044cbdb58b04bcb11/1.0.2?referer=%2Fstore%2Fsearch%3Flistingtype%3Dallintegrations%25253Bancillary_app%25253Bcertified_apps%25253Bcontent%25253Bindustry_solution%25253Boem%25253Butility%25253Btemplate%26q%3Dharness\&sl=sh) before using templates to create ServiceNow tickets.
* Make sure you have the following roles:
  * `x_harne_harness_ap.integration_user_role` to access templates.
  * `itil` for end-to-end integration with Harness.
    {% endhint %}

***

## Required ServiceNow integration app for Harness templates

The Integration for Harness Software Delivery Platform app is required to create ServiceNow tickets using **ServiceNow Form templates**. You can install the latest version of the Integration for Harness Software Delivery Platform app in your ServiceNow instance from the [ServiceNow store](https://store.servicenow.com/sn_appstore_store.do#!/store/application/de154a1e1b75851044cbdb58b04bcb11/1.0.2?referer=%2Fstore%2Fsearch%3Flistingtype%3Dallintegrations%25253Bancillary_app%25253Bcertified_apps%25253Bcontent%25253Bindustry_solution%25253Boem%25253Butility%25253Btemplate%26q%3Dharness\&sl=sh).

This integration is supported for the following ServiceNow versions:

* Vancouver
* Washington DC
* Xanadu
* Yokohama
* Zurich
* Australia

Go to the [ServiceNow installation guide](https://store.servicenow.com/appStoreAttachments.do?sys_id=1fc1632b872f4dd0970e2178cebb35ba) to review the installation steps.

{% hint style="warning" %}
**Provide datetime values in UTC**

The ServiceNow API only allows date and time values in the UTC timezone. Consequently, input for any datetime/time fields in Harness ServiceNow steps must be provided in UTC format, irrespective of time zone settings in your ServiceNow account.

The timezone settings govern the display value of the settings, not their actual value. The display values in the Harness UI depend on ServiceNow's timezone settings.
{% endhint %}

***

## Add a ServiceNow Create step

Perform the following steps to add a ServiceNow Create step:

1. In the Harness Deploy or Approval stage, select Execution, then select **Add Step**.

   ![Add Step menu in a Harness Deploy or Approval stage Execution](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-84415592749b0fd626761de8f4657801f5031ee6%2Fcreate-service-now-tickets-in-cd-stages-05.png?alt=media)
2. Select **ServiceNow Create**. The ServiceNow Create settings appear.

   ![ServiceNow Create step settings](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-e203e555a4a1ee0af148e704117d71caf1771b6e%2Fcreate-service-now-tickets-in-cd-stages-06.png?alt=media)
3. In **Name**, enter a name that describes the step.
4. In **Timeout**, enter how long you want Harness to try to create the issue before failing (and initiating the stage or step [failure strategy](https://developer.harness.io/docs/platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps)).
5. In **ServiceNow Connector**, create or select the [ServiceNow connector](https://developer.harness.io/docs/platform/connectors/ticketing-systems/connect-to-service-now) to use.
6. In **Ticket Type**, select a ServiceNow ticket type from the list.

   ![Ticket Type field on the ServiceNow Create step](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-046a326367f23400033e3474b9251d2ada835a15%2Fcreate-service-now-tickets-in-cd-stages-07.png?alt=media)

***

## Configure fields

Perform the following steps to configure the ticket fields:

1. Select **Configure Fields** to select or add ServiceNow Fields to your ServiceNow ticket. This option enables you to access multiple custom fields from your ServiceNow integration.
2. In **Description**, add the ticket description.
3. In **Short Description**, enter a description of the ticket you are creating. This is the title of the ticket. You can use Harness variables in the **Short Description** and **Description** fields.
4. Select **Fields**. The **Add ServiceNow Fields** settings appear.

   ![Add ServiceNow Fields dialog](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-ec864a20eadb5ae12a026a4c8867ddf734c57947%2Fcreate-service-now-tickets-in-cd-stages-08.png?alt=media)
5. Select the **Provide Field List** to add custom fields.
6. Enter **the Key** for the field.
7. In **Value**, you can write static values or variables to these fields. The properties are specified as key-value pairs, with the key being the field name (not the label) in ServiceNow and a valid value.
8. Select **Add**.

   ![Custom field key and value added to the ServiceNow Create step](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-ad878599b333a281b82288bc319aa26397648f7c%2Fcreate-service-now-tickets-in-cd-stages-09.png?alt=media)

   When you are done, the dialog looks like the following:

   ![ServiceNow Create step with configured fields](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-e1d41e98bc5abfd31606fd7fc042158a9b9cce80%2Fcreate-service-now-tickets-in-cd-stages-10.png?alt=media)

***

## Create from form template

Form Templates are a generic concept in ServiceNow that allows you to create templates containing commonly used field values for any table. These templates can be applied to any table in ServiceNow, not just specific ticket types. Form templates have the following characteristics:

* **Applicability**: Valid for any table in ServiceNow
* **Purpose**: Pre-populate commonly used field values to speed up ticket creation
* **Implementation**: Harness relies on the `sys_template` table in ServiceNow that stores form templates for all tables
* **Documentation**: Go to the [ServiceNow documentation on creating templates](https://www.servicenow.com/docs/bundle/washingtondc-platform-administration/page/administer/form-administration/task/t_CreateATemplateUsingTheTmplForm.html) to review Form Templates in ServiceNow.

Select **Create From Form Template** to create a ticket by using an existing form template in your ServiceNow integration.

In **Template Name**, you can enter the name of an existing template, select from the list of existing templates displayed when you select the field, or provide an expression. You can also search for the templates you need.

{% hint style="info" %}
**Requirements for searching form templates**

Make sure you have met the following requirements for searching form templates:

* Harness Delegate version 81200 or later.
* Integration for Harness Software Delivery Platform app version 1.0.2 or later.

**Technical Implementation Details**

* The API calls for form templates are implemented as scripts in the Harness ServiceNow app. The delegate calls these internal scripted APIs.
* The implementation is not open-sourced, but Harness can provide implementation details if required.
  {% endhint %}

This option updates tickets with values as defined in the linked form template for the associated table. This is achieved via scripted APIs defined in the ServiceNow integration app for Harness templates. If there are many templates with the same name, the most current one is used to create tickets. Select **Apply Changes**.

Your ServiceNow ticket is now added to your pipeline.

You can also set the template name as a Runtime Input, allowing you to see a dropdown list of available templates during runtime.

![Template Name runtime input dropdown for form templates](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-02390dee9c5ff989bb8ec8d920f83c117727d6a3%2Fservice-now-template-dropdown-1.png?alt=media)

If the selected template has fields, the associated secondary fields are displayed for configuration.

![Secondary fields from a selected ServiceNow form template](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-2677cb4c59d49db55d9b7264625820e502d95141%2Fservice-now-template-dropdown-2.png?alt=media)

Additionally, a dropdown for templates is also provided when configuring Triggers and Input Sets for this step.

***

## Create from a standard template

Standard Templates are a specific module in ServiceNow designed to enable faster, low-impact, high-frequency changes. These templates are pre-approved by change managers, allowing users with lower privileges to create change requests. Standard templates have the following characteristics:

* **Applicability**: Specific to Change Request tickets only
* **Purpose**: Enable faster creation of pre-approved change types
* **Approval**: Standard templates are pre-approved by change managers
* **Relationship with Form Templates**: For each standard template, ServiceNow creates an internal form template. This is why standard change templates also appear in the form templates list, but the experience is better when using the standard template flow specifically for standard templates.

{% hint style="info" %}
**Delegate version for standard templates**

This feature requires Harness Delegate version 81200 or later.

The Harness Software Delivery Platform app is **not required to create** standard change requests using this feature.
{% endhint %}

This option appears only when the value type in the **Ticket Type** field is **Fixed value**, and the ServiceNow ticket type specified is **Change Request**. This feature can be used to create low-risk standard change requests using pre-approved standard templates.

Select **Create From Standard Template** to create a ticket by using an existing standard template in your ServiceNow integration.

In **Template Name**, you can enter the name of an existing template, select from the list of existing templates displayed when you select the field, or provide an expression. You can also search the templates you need.

If there are many templates with the same name, the most current one is used to create tickets. Select **Apply Changes**.

You can also set the template name as a Runtime Input, allowing you to see a dropdown list of available templates during runtime.

If the selected template has fields, the associated secondary fields are displayed for configuration.

Your ServiceNow ticket is now added to your pipeline. After a standard template is loaded, fields are marked editable based on `Standard Change Properties` whether the `change_manager` role is present with the integration user. Otherwise, the properties cannot be fetched, and fields are read-only by default, as per the ServiceNow documentation.

The fields ignored in the process of standard change creation are available in the step output as `ignoredFields` in `fields`.

![ignoredFields in the ServiceNow Create step output](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-8822a328d86061252dab4338874021268a564a62%2Fcreate-service-now-tickets-in-cd-stages-14.png?alt=media)

{% hint style="info" %}
**Standard change template references**

Go to [Change Management - POST /sn\_chg\_rest/change/standard/standard\_change\_template\_id](https://docs.servicenow.com/bundle/utah-api-reference/page/integrate/inbound-rest/concept/change-management-api.html#title_change-POST-standard). [Best practice: Make the most of standard changes](https://www.servicenow.com/community/itsm-blog/best-practice-make-the-most-of-standard-changes/ba-p/2267543) and [Standard Change Properties](https://support.servicenow.com/kb?id=kb_article_view\&sysparm_article=KB0716365) to review ServiceNow standard change behavior.
{% endhint %}

***

## Normal and standard change requests

By default, Harness creates Normal Change requests, not Standard Change requests. Perform the following steps to create Standard or Emergency type ServiceNow Change request tickets:

1. In **Fields**, select **Type**.

   ![Type field on the ServiceNow Create step](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-a1fc4e20c9cff35d7732520ebb9f62837fbf1c24%2Fcreate-service-now-tickets-in-cd-stages-12.png?alt=media)
2. In **Type**, select **Normal** or **Emergency**.

   ![Normal or Emergency type options for a change request](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-764a00ce6c85a7c93b9b8cad2b5cdccfc4668066%2Fcreate-service-now-tickets-in-cd-stages-13.png?alt=media)

***

## Custom table support

Custom table support is available in the Harness ServiceNow integration as part of the **Ticket Type** setting.

![Ticket Type field showing a custom table name](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-72e4c03cb4a78a98f5b8f89de4092f70ace01b46%2Fbcbbdbca197e5323c43f669c0e22b23f1bccea47c48264685c59cd69491af1e8.png?alt=media)

This feature is available in ServiceNow Create and Update steps.

{% hint style="warning" %}
**Use a table that extends the task**

Harness recommends that you only use a table that extends the task, or extend tables that indirectly extend the task.
{% endhint %}

You can specify any custom table in Harness by typing the table name in the **Ticket Type** setting.

<details>

<summary>What is a table extending task?</summary>

In ServiceNow, a table extending task is a task that involves creating a new table by extending an existing table. When a table is extended, a new child table is created that inherits all the fields, relationships, and other attributes of the parent table. The child table can then be customized further to meet the specific needs of the organization.

</details>

Harness supports two use cases, and you need sufficient permissions for each use case:

* **Standard use case**: You should have sufficient permissions on the custom table, such as basic create, read, and update permissions. You also need any additional permissions required to update specific fields within that custom table, if required.
* **Template use case**: This is covered in "Use custom tables with the template flow.

For standard use cases, the custom table should allow access to it via web services.

![ServiceNow table setting that allows access via web services](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-0459aa8d84df2626df3e88e182b8ecc1ead369f7%2Ff435a9ea3265d0696da26c80efd5bf8c6c2ff329f7c1a667727d294ef15d8c84.png?alt=media)

### Use custom tables with the template flow

This section describes how to use custom tables via the Harness ServiceNow app in the ServiceNow store.

{% hint style="info" %}
**Custom tables with the Harness store app**

* Cross-scope privileges must be added for the ServiceNow user only when using custom tables with templates (via the Harness app on the ServiceNow store).
* The store app is certified by the ServiceNow certification team to be used only with the Incident, Problem, Change Request, and Change Task tables.
  {% endhint %}

Perform the following steps to use custom tables via the Harness ServiceNow app:

1. Add three (create, read, write) cross-scope privileges from the **harness-app** to the global scope with the target name as the table name (`u_st` in this example) and set the **Status** as **Allowed**.

   ![Cross-scope privileges for a custom ServiceNow table](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-8ff825b772e6f04e537add4697cbd96c403167f0%2F7c4ff638b97d3452edca6e45cc4ff70fe64134dde21b56eedd3e7b7aa33575e6.png?alt=media)

   ![ServiceNow custom tables configuration walkthrough](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-dc6fd04e06e1ed188aae70eb42f8ee0626a22ed3%2Fservicenow-custom-tables.gif?alt=media)
2. The ServiceNow user should be granted the read permission on the custom table at a minimum. In most cases, this is achieved with the **ITIL** role only.
3. The custom table being used should allow access to this table via web services.

   ![ServiceNow table setting that allows access via web services](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-0459aa8d84df2626df3e88e182b8ecc1ead369f7%2Ff435a9ea3265d0696da26c80efd5bf8c6c2ff329f7c1a667727d294ef15d8c84.png?alt=media)

***

## Troubleshooting

The following issues are common when you create ServiceNow tickets from a CD or Approval stage:

<details>

<summary>Each pipeline run creates a new ServiceNow ticket</summary>

The ServiceNow Create step always creates a new ticket. If you need to update an existing ticket, use the Update ServiceNow step instead. Go to [Update ServiceNow tickets in CD stages](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/update-service-now-tickets-in-cd-stages.md) to configure updates.

</details>

<details>

<summary>Form template search or apply fails</summary>

Confirm that the Integration for Harness Software Delivery Platform app is installed, that the integration user has `x_harne_harness_ap.integration_user_role` and `itil`, and that the Harness Delegate is version 81200 or later for form template search.

</details>

<details>

<summary>Datetime fields are rejected or display incorrectly</summary>

Provide datetime and time field values in UTC. ServiceNow account timezone settings affect display values only, not the values Harness sends through the API.

</details>

***

## Next steps

* [Update ServiceNow tickets in CD stages](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/update-service-now-tickets-in-cd-stages.md): Triggered by a pipeline step.
* [Import data into ServiceNow](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/servicenow-import-set.md) using a staging table.
* [ServiceNow create, update, and approval API permissions](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/servicenow-api-permission.md): Review the permissions required by the ServiceNow steps.

{% @harness-feedback/feedback %}
