> 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/servicenow-import-set.md).

# Import data into ServiceNow

Import data using a staging table.

You can use the **ServiceNow Import Set** step in your Deploy, Approval, or Custom stages to import data to your instance using an import set table as a staging area.

## What you will learn from this topic

* How to identify the [required ServiceNow roles](#required-servicenow-roles).
* How to [add a ServiceNow Import Set step](#add-a-servicenow-import-set-step), [select the staging table](#select-the-stage-table), and [enter the JSON body](#enter-the-json-body).
* How to [review transform map outcomes](#review-transform-map-outcomes) and reference them in later steps.

***

## Before you begin <a href="#required-servicenow-roles" id="required-servicenow-roles"></a>

Before you add the step, make sure the integration user has the required ServiceNow roles. You also need a [Harness ServiceNow connector](/harness-platform/use-harness-platform/connectors/ticketing-systems/connect-to-service-now.md), which you can add during step setup.

**Required ServiceNow roles**

The integration user must have the following minimal permissions to execute a ServiceNow import set step:

* `import_transformer`.
* Role mapping to CRUD permissions on the staging table.
* Roles mapping to READ permissions for each of the target tables that have an existing transform map from the specified staging table to the target table.
* (If required) Permissions for fetching specific staging tables.
* Permission to access table `sys_db_object`. This is optional because you can enter your own staging table instead of selecting prefetched values.

{% hint style="info" %}
You can also create and update tickets using the following Harness ServiceNow steps:

* [Create ServiceNow tickets in CD stages](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/create-service-now-tickets-in-cd-stages.md)
* [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)
  {% endhint %}

***

## Import set summary <a href="#import-set-summary" id="import-set-summary"></a>

In ServiceNow, an import set is a staging table that contains a temporary copy of data to import into the platform. Import sets can be used to import data from a variety of sources, such as CSV files or JDBC-compliant databases. You can transform that data into a format that can be loaded into ServiceNow tables.

Import Sets are a useful tool for migrating data into ServiceNow, or for regularly importing data from external systems into the platform.

{% hint style="info" %}
For more information on ServiceNow import sets, go to [Import Set - POST /now/import/{stagingTableName}](https://docs.servicenow.com/bundle/quebec-application-development/page/integrate/inbound-rest/concept/c_ImportSetAPI.html#import-POST) and [import sets key concepts](https://docs.servicenow.com/en-US/bundle/tokyo-platform-administration/page/administer/import-sets/concept/c_ImportSetsKeyConcepts.html) from ServiceNow.
{% endhint %}

***

## Add a ServiceNow Import Set step <a href="#add-a-servicenow-import-set-step" id="add-a-servicenow-import-set-step"></a>

You can add a ServiceNow Import Set step anywhere in Deploy, Approval, or Custom stages where you need to import data using a staging table. Perform the following steps to add the step:

1. In a Harness Deploy, Approval, or Custom stage, in **Execution**, click **Add Step**, and then select **ServiceNow Import Set**.
2. Enter a name for the step.
3. Enter a timeout period for the step. After the timeout expires, Harness initiates the step or stage [failure strategy](/harness-platform/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md).
4. In **ServiceNow Connector**, select or create the [Harness ServiceNow connector](/harness-platform/use-harness-platform/connectors/ticketing-systems/connect-to-service-now.md) to use.

***

## Select the staging table <a href="#select-the-stage-table" id="select-the-stage-table"></a>

The **Staging Table** setting specifies the staging table used to import data into ServiceNow. These intermediate table names extend the **Import Set Row** table in ServiceNow.

In **Staging Table**, select or enter the staging table to use. The list is populated using the ServiceNow connector you added in **ServiceNow Connector**.

***

## Enter the JSON body <a href="#enter-the-json-body" id="enter-the-json-body"></a>

The **JSON Body** setting contains the JSON that this step passes when it makes a call to the ServiceNow Import Set API.

For example, to initiate a transformation using the `sys_import_state_comment` field of the selected staging table based on its transformation map, use JSON like the following:

```json
{"sys_import_state_comment":"my comment"}
```

You can also use Harness runtime inputs, variable expressions, and Harness secrets in the JSON of **JSON Body**.

For example, create a stage variable named `importset` and then reference it in **JSON Body** as `{"u_example":"<+stage.variables.importset>"}`.

For details on the table requirements and naming, go to [import sets](https://docs.servicenow.com/en-US/bundle/tokyo-platform-administration/page/administer/import-sets/reference/import-sets-landing-page.html) from ServiceNow.

For details on creating a transform map, go to [create a transform map](https://docs.servicenow.com/bundle/tokyo-platform-administration/page/script/server-scripting/task/t_CreateATransformMap.html).

***

## Advanced settings <a href="#advanced-settings" id="advanced-settings"></a>

In **Advanced**, you can configure the following options for the step:

* [Delegate Selector](/harness-platform/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors.md)
* [Conditional Execution](/harness-platform/use-harness-platform/pipelines/step-skip-condition-settings.md)
* [Failure Strategy](/harness-platform/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md)
* [Looping Strategy](/harness-platform/use-harness-platform/pipelines/looping-strategies/looping-strategies-matrix-repeat-and-parallelism.md)
* [Policy Enforcement](/harness-platform/use-harness-platform/governance/policy-as-code/harness-governance-overview.md)

***

## Review transform map outcomes <a href="#review-transform-map-outcomes" id="review-transform-map-outcomes"></a>

Within ServiceNow, **Transform Table Maps** determine how data is written from the staging table to existing target tables. Map rows determine whether the transformation creates or updates a ticket, and determines the ticket type.

![Transform Table Maps](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-606f76f89af20be5ccdff2062cc4001a34b56160%2Fservicenow-transform-table.png?alt=media)

You can view the outcomes of transform maps after the pipeline is run. Perform the following steps to view them:

1. Click the **ServiceNow Import Set** step in the executed pipeline.
2. Click the **Output** tab.

You can see the results in the **Transform Map Outcomes** table for each record.

![Transform Map Outcomes](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-ed9c5c274e8407875e5c3340956e3e7894f0978d%2Fservicenow-outputs.png?alt=media)

To reference these results as expressions in other pipeline steps, click the copy button next to the **Output Name**. The result is expressions like the following:

```
<+pipeline.stages.stage1.spec.execution.steps.step1.output.transformMapOutcomes[0].transformMap>
<+pipeline.stages.stage1.spec.execution.steps.step1.output.transformMapOutcomes[0].status>
<+pipeline.stages.stage1.spec.execution.steps.step1.output.transformMapOutcomes[1].transformMap>
<+pipeline.stages.stage1.spec.execution.steps.step1.output.transformMapOutcomes[1].status>
```

You can echo them in a subsequent step, such as a [Shell Script step](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/utilities/shell-script-step.md).

{% hint style="info" %}
**Custom fields**

Use custom fields instead of out-of-the-box fields in transform maps, especially when an import set staging table has more than one associated transform map.
{% endhint %}

***

## Next steps

* [Create ServiceNow tickets in CD stages](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/create-service-now-tickets-in-cd-stages.md): Create ServiceNow tickets from a pipeline step.
* [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): Update ServiceNow tickets from a pipeline step.
* [Shell Script step](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/utilities/shell-script-step.md): Echo transform map outcomes in a later step.

{% @harness-feedback/feedback %}
