> 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-multi-config-items.md).

# Add multiple configuration items to ServiceNow change requests

Harness enables you to add multiple existing configuration items to a existing change request in ServiceNow.

To set up the pipeline, you use two Harness ServiceNow Create steps. The first step creates the change request and obtains a `sys_id`. The second step uses the `sys_id` to get the task and add the config items.

This topic walks you through the setup procedure.

### Pipeline example YAML <a href="#pipeline-example-yaml" id="pipeline-example-yaml"></a>

You can use the following pipeline YAML as an example of how to set up this solution.

<details>

<summary>Pipeline example YAML</summary>

```yaml
pipeline:
  projectIdentifier: myproject
  orgIdentifier: default
  tags: {}
  stages:
    - stage:
        name: stage
        identifier: stage
        description: ""
        type: Custom
        spec:
          execution:
            steps:
              - step:
                  type: ServiceNowCreate
                  name: create
                  identifier: create
                  spec:
                    useServiceNowTemplate: false
                    connectorRef: account.service_now_connector
                    ticketType: change_request
                    fields: []
                  timeout: 10m
              - step:
                  type: ServiceNowCreate
                  name: ServiceNowCreate_1
                  identifier: ServiceNowCreate_1
                  spec:
                    useServiceNowTemplate: false
                    connectorRef: account.service_now_connector
                    ticketType: task_ci
                    fields:
                      - name: ci_item
                        value: <+matrix.ci_item>
                      - name: task
                        value: <+pipeline.stages.stage.spec.execution.steps.create.ticket.fields.sys_id>
                  timeout: 10m
                  strategy:
                    matrix:
                      ci_item:
                        - 9ea9e3491bb971100269a608624bcb85
                        - 43b89fa11b6139100269a608624bcb6f
                      maxConcurrency: 2
        tags: {}
  identifier: mypipeline
  name: mypipeline

```

</details>

### Assign multiple config items as part of the change request <a href="#assign-multiple-config-items-as-part-of-the-change-request" id="assign-multiple-config-items-as-part-of-the-change-request"></a>

Use the following steps to set up the pipeline and ServiceNow Create steps.

#### Add the first ServiceNow Create step to a pipeline stage <a href="#add-the-first-servicenow-create-step-to-a-pipeline-stage" id="add-the-first-servicenow-create-step-to-a-pipeline-stage"></a>

1. In your pipeline stage (Deploy, Custom, or Approval), add a ServiceNow Create step.
2. In **ServiceNow Connector**, create or select a [Harness ServiceNow connector](/harness-ai/use-harness-platform/connectors/ticketing-systems/connect-to-service-now.md) to connector to you ServiceNow server.
3. In **Ticket Type**, select **Change Request**.
4. Select **Apply Changes**.

When you run the pipeline, this step will output a `sys_id`. You will use a Harness expression to reference this value in the next ServiceNow Create step's **Task** setting.

The expression follows this format:

```
<+pipeline.stages.stage.spec.execution.steps.STEP_ID.ticket.fields.sys_id>
```

For example:

```
<+pipeline.stages.stage.spec.execution.steps.create.ticket.fields.sys_id>
```

#### Add the second ServiceNow Create step to a pipeline stage <a href="#add-the-second-servicenow-create-step-to-a-pipeline-stage" id="add-the-second-servicenow-create-step-to-a-pipeline-stage"></a>

1. In your pipeline stage (Deploy, Custom, or Approval), add a ServiceNow Create step.
2. In **ServiceNow Connector**, create or select a [Harness ServiceNow connector](/harness-ai/use-harness-platform/connectors/ticketing-systems/connect-to-service-now.md) to connector to you ServiceNow server.
3. In **Ticket Type**, select the type or enter a custom type. In the YAML example earlier in this topic, we use a custom table named `task_ci`.
4. In **Configure Fields**, select **Fields**.
5. In **Add ServiceNow Fields**, select **Configuration Item** and **Task**, and select **Add**.

<figure><img src="/files/Vg4CgLalojl3RSdo5JYr" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

1\. In \*\*Configuration Item\*\*, select \*\*Expression\*\*, and then enter \`<+matrix.ci\_item>\`. This expression references the step's looping strategy we will add later. 2. In \*\*Task\*\*, select \*\*Expression\*\*, and then enter the expression that references the sys\_id in the previous ServiceNow Create step, using the format \`<+pipeline.stages.stage.spec.execution.steps.STEP\_ID.ticket.fields.sys\_id>\`. For example, \`<+pipeline.stages.stage.spec.execution.steps.create.ticket.fields.sys\_id>\`.

This expression references the `sys_id` value returned when the step in run.

<figure><img src="/files/dtozOeGjc5OJanM7OgQ9" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

Next, we will add the looping strategy for the step.

#### Add a matrix looping strategy <a href="#add-a-matrix-looping-strategy" id="add-a-matrix-looping-strategy"></a>

The matrix looping strategy will loop through the config items.

1. In the ServiceNow Create step, select **Advanced**.
2. In **Looping Strategy**, enter the following:

```
matrix:
  ci_item:
    - Config item Id
    - Config item Id
    - etc
  maxConcurrency: number of items
```

For example:

```
matrix:
  ci_item:
    - 9ea9e3491bb971100269a608624bcb85
    - 43b89fa11b6139100269a608624bcb6f
  maxConcurrency: 2
```

3. Select **Apply Changes**.

### Run the pipeline <a href="#run-the-pipeline" id="run-the-pipeline"></a>

When you run the pipeline, you will see the looping strategy run for each config item Id in the step's matrix.

<figure><img src="/files/U9nPrnQe9CrWT74sjdVY" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

Select the link in the step **Output** tab's **ticketUrl** to open a new browser tab and view the config item.
