---
schema_version: "1"
id: e4113f637b7128ca369505042f652f6ad89b3371e5b3919809997bd5e78b3c17
title: ServiceNow Connector 6.17 Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/servicenow-connector/6.17/servicenow-connector-examples.md
canonical_url: https://docs.mulesoft.com/servicenow-connector/6.17/servicenow-connector-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 25c74c5c262458c7c07d086983238bbf2105dbd22adce8ffe3e95670b48dc30c
description: MuleSoft Documentation Site
release: "6.17"
latest: false
---
---
product: ServiceNow Connector
version: 6.17
---

# ServiceNow Connector 6.17 Examples

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

To fully benefit from using Anypoint Connector for ServiceNow (ServiceNow Connector), see the
following examples.

## Retrieve Records from a ServiceNow Incident Table

This example creates a Mule flow that retrieves records from the `Incident` table. The following
screenshot shows the Studio app flow for this example:

![ServiceNow flow for incident get records](/mulesoft/current/en-us/servicenow-connector/6.17/_images/servicenow-flow-incident-getrecords.png)

Figure 1. App flow for the Retrieve Records example

1.  Create a Mule project in Studio.

2.  Add and configure an **HTTP Listener** trigger for your flow with this path:

    `getrecords`

    ![HTTP Listener general settings with path set to getrecords](/mulesoft/current/en-us/servicenow-connector/6.17/_images/servicenow-listener.png)

3.  Add a **Transform Message** component after the HTTP connector and provide a transformation
    script similar to this:

    %dw 2.0 output application/xml ns ns0 http://www.service-now.com/incident
    ---

    { ns0#getRecords: { ns0#description: 'Test WSDL QA' } }

    > [!NOTE] Add a description that matches records in your ServiceNow incident table.

4.  Add the **Invoke** operation from ServiceNow after the **Transform** component.

5.  Set up, test, and save a ServiceNow configuration for the connection to the ServiceNow server.
    If the connection is unsuccessful, correct any invalid connection parameters, and test again.

    ![Global element properties window](/mulesoft/current/en-us/servicenow-connector/6.17/_images/servicenow-studio-connection-6.6.0.png)

    ![Transport tab in global element properties window](/mulesoft/current/en-us/servicenow-connector/6.17/_images/servicenow-studio-config-transport-tab.png)

6.  In the **General** tab in the navigation, set **Service** to `incident` and **Operation** to
    `getRecords`.

7.  Optionally, choose **Show Reference Values** from the values (`ALL`, `TRUE`, `FALSE`)

    > [!IMPORTANT] In Studio 7.5.0 and later, you can choose the `service` and `operation` keys
    > without specifying the `Show Reference Values` key to resolve the metadata. However, in
    > earlier Studio versions, metadata won’t be loaded until you specify all of the metadata keys,
    > and if you don’t specify all of the metadata keys, it results in a tooling exception.

    ![ServiceNow metadata without reference values](/mulesoft/current/en-us/servicenow-connector/6.17/_images/servicenow-metadata-without-reference-values.png)

8.  Set the Message Body to `payload`.

9.  Add the **Transform Message** component to `transform XML to JSON` for better readability. For
    example:

    %dw 2.0 output application/json
    ---

    payload

10. Add a **Logger** component to the end of your flow that takes a `payload` (or `#[payload]`) as
    the message.

11. Deploy or run your app.

12. Test the app by navigating to `http://localhost:8081/getrecords`

The response should look similar to this example (several fields are omitted for brevity):

{ "headers": {

}, "attachments": {

}, "body": { "getRecordsResponse": { "getRecordsResult": { "active": "1", "activity\_due":
"2019-09-24 09:48:15", "approval": "not requested", "business\_stc": "0", "calendar\_stc": "0",
"category": "Software", "child\_incidents": "0", "description": "Test WSDL QA", "escalation": "0",
"hold\_reason": "0", "impact": "1", "incident\_state": "1", "knowledge": "0", "made\_sla": "1",
"notify": "1", "number": "INC0011616", "opened\_at": "2019-09-20 07:30:34", "opened\_by":
"6816f79cc0a8016401c5a33be04be441", "order": "0", "priority": "1", "reassignment\_count": "0",
"reopen\_count": "0", "severity": "3", "state": "1", "sys\_class\_name": "incident",
"sys\_created\_by": "admin", "sys\_created\_on": "2019-09-20 07:30:34", "sys\_domain": "global",
"sys\_domain\_path": "/", "sys\_id": "c03deab4db840010a0e6e04a48961999", "sys\_mod\_count": "47",
"sys\_updated\_by": "system", "sys\_updated\_on": "2019-09-24 07:48:15", "upon\_approval":
"proceed", "upon\_reject": "cancel", "urgency": "1", } } } }

If you use `ALL` for `Show Reference Values`, the response is similar to this abbreviated output, in
which the response element name for the display value field begins with `dv`:

{ "headers": {

}, "attachments": {

}, "body": { "getRecordsResponse": { "getRecordsResult": { "active": "1", "dv\_active": "true",
"activity\_due": "2020-05-07 13:14:19", "dv\_activity\_due": "2020-05-07 06:14:19",
"additional\_assignee\_list": null, "dv\_additional\_assignee\_list": null, "approval": "not
requested", "dv\_approval": "Not Yet Requested", } } } }

The response element name for the display value field is prefixed with `dv`.

## Retrieve ServiceNow Incident Table Keys

This example creates a Mule flow that retrieve keys from the Incident table in a ServiceNow
instance:

1.  Create a Mule application as a project in Studio.

2.  Add and configure an HTTP **Listener** trigger for your flow, and set the **Path** to
    `/getkeys`.

3.  Add a **Transform Message** component after the HTTP **Listener** operation.

4.  Provide a transformation script similar to this (use a description that matches records in your
    ServiceNow incident table):

    %dw 2.0 output application/xml ns ns0 http://www.service-now.com/incident
    ---

    { ns0#getKeys: { ns0#description: 'Test WSDL QA' } }

5.  Add the ServiceNow **Invoke** operation after the **Transform Message** component.

6.  Set up, test, and save a ServiceNow configuration for the connection to the ServiceNow server.
    If the connection is unsuccessful, correct any invalid connection parameters and test again.

7.  In the **General** tab navigation, set **Service** to `incident` and **Operation** to `getKeys`.

8.  Set the Message Body to `payload`.

9.  Add the **Transform Message** component to transform XML to JSON for better readability. For
    example:

    %dw 2.0 output application/json
    ---

    payload

10. Add a **Logger** component to the end of your flow that takes a `payload` (or `#[payload]`) as
    the message.

11. Deploy or run your app.

12. To test the app, navigate to: `http://localhost:8081/getkeys`

13. The response should look similar to this:

    { "headers": {

    }, "attachments": {

    }, "body": { "getKeysResponse": { "sys\_id":
    "c03deab4db840010a0e6e04a48961999,0f517ab8db840010a0e6e04a489619bc,6f1236f8db840010a0e6e04a489619f5",
    "count": "3" } } }

## See Also

- [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)

- [Using Anypoint Studio to Configure ServiceNow Connector](https://docs.mulesoft.com/servicenow-connector/6.17/servicenow-connector-studio)

- [Salesforce Help](https://help.salesforce.com)
