Select

The ServiceNow Connector facilitates connections between Mule integration and ServiceNow applications. The ServiceNow Connector v5 provides these operations: aggregate, deleteMultiple, deleteRecord, get, getKeys, getRecords, insert, insertMultiple, and update. You can use these operations with the custom ServiceNow tables, along with any operations available through the installed plugins.

The XML element for the ServiceNow configuration starts with the servicenow: statement.

About Prerequisites

This document assumes that you are familiar with Mule, Anypoint Connectors, and the Anypoint Studio interface. To increase your familiarity with Studio, consider completing one or more Anypoint Studio Tutorials. Further, this page assumes that you have a basic understanding of Mule flows and Global Elements in Mule.

For this connector to discover available operations, your ServiceNow user account has to have at least read access for the Name and Label fields in the sys_db_object and sys_db_view tables.

The ServiceNow API relies on HTTP Basic authentication which is the default authentication system to make an HTTP request.

About Compatibility

This version of the ServiceNow connector is compatible with:

Application/Service Version

Mule Runtime

3.7.0 or later

ServiceNow

Eureka, Fuji, Geneva, Helsinki, Istanbul, London and New York (default)

The ServiceNow connector has been tested with the Eureka, Fuji, Geneva, Helsinki, Istanbul, London and New York (default) versions of ServiceNow. It may work with other versions of ServiceNow as well, but the compatibility of the connector with another version has not been tested.

The ServiceNow connector is not compatible with Mule Runtime versions prior to 3.7.

To Install this Connector

  1. In Anypoint Studio, click the Exchange icon in the Studio taskbar.

  2. Click Login in Anypoint Exchange.

  3. Search for the connector and click Install.

  4. Follow the prompts to install the connector.

When Studio has an update, a message displays in the lower right corner, which you can click to install the update.

To use the ServiceNow connector v5 in a production environment, you must have an Enterprise license to use Mule. Contact the MuleSoft Sales Team to obtain this license. See: Installing an Enterprise License.

To Create a New Project

To use the ServiceNow connector in a Mule application project:

  1. In Studio, click File > New > Mule Project.

  2. Enter a name for your new project and leave the remaining options with their default values.

  3. If you plan to use Git, select Create a .gitignore File for the project with default ignore settings for Studio Projects, and click Next.

  4. Click Finish to create the project.

  5. Search for http and drag the HTTP connector to the canvas.

  6. Click the green plus sign next to Connector Configuration and accept the default settings for the HTTP connector.

  7. Search for servicenow and drag the ServiceNow connector to the canvas.

  8. Click the green plus sign next to Connector Configuration and choose either the basic or advanced configuration.

To Configure a ServiceNow Basic Configuration

The Basic configuration only supports basic authentication. You can specify ServiceNow login credentials from this menu:

servicenow config
Field Description

Name

Enter a name for the configuration so it can be referenced later.

Username

Username for connecting to the ServiceNow instance.

Password

Password to log into the ServiceNow instance.

Service Address

The URL of your ServiceNow address, for example: https://myservicenow.service-now.com

ServiceNow Version

Select the version of your ServiceNow instance. The default is ISTANBUL.

User Table List

  • Default — DataSense does not fetch user (or custom) tables.

  • Create Object Manually — Click the …​ symbol to add entries to the list. Only user (or custom) tables can be acquired by DataSense. In Object Builder, click the green plus sign to add a String entry. Right-click the entry to edit the metadata value for the entry (the Entry name cannot be changed).

Notes:

  • ServiceNow lets you create Custom Tables or Views. To access these, use the User Table List field.

  • To fetch available tables and view, make a call to /api/now/table/sys_db_object and /api/now/table/sys_db_view, otherwise, the connector won’t be able to display available operations and input/output parameters for them. You can create a role with read writes on sys_db_object and sys_db_view, which can be limited to "name" and "label" fields as these are the ones of most interest, and associate those rules to your integration user without being forced to give admin rights to the integration user.

  • The placeholder values refer to a configuration file placed in the src folder of your project. See Learn how to configure properties. You can either enter your credentials into the global configuration properties, or reference a configuration file that contains these values. For simpler maintenance and better re-usability of your project, use a configuration file. Keeping these values in a separate file is useful if you need to deploy to different environments, such as production, development, and QA, where your access credentials differ. See Deploying to Multiple Environments for instructions on how to manage this.

To Configure a ServiceNow Advanced Configuration

The Advanced configuration supports additional authentication options.

Using the advance configuration, connection settings like Connection Idle Timeout and Response Timeout can also be configured. You can configure them by modifying HTTP Request Configuration global element that you choose for HTTP Request Config.

The Advanced configuration requires that you specify ServiceNow login credentials from the HTTP connector. For information on each HTTP authentication parameter, see Authentication in HTTP Requests.

Important
While the ServiceNow Advanced Configuration exposes various configurations of HTTP Request, the connector only supports Basic Authentication, proxy setting, Connection Idle Timeout, and Response Timeout.
servicenow advanced config
Field Description

Name

Enter a name for the ServiceNow configuration.

HTTP Request Config

Select an HTTP Request configuration. Note: The HTTP Request connector configuration appears in the XML flow view, but does not appear in the Studio Message Flow.

Service Address

The URL of your ServiceNow address, for example: https://myservicenow.service-now.com

ServiceNow Version

Select the version of your ServiceNow instance. The default is ISTANBUL.

User Table List

  • Default — DataSense does not fetch user (or custom) tables.

  • Create Object Manually — Click the …​ symbol to add entries to the list. Only user (or custom) tables can be acquired by DataSense. In Object Builder, click the green plus sign to add a String entry. Right-click the entry to edit the metadata value for the entry (the Entry name cannot be changed). See also: table notes.

Click Validate Config to test your ServiceNow access credentials.

servicenow advanced basic auth

To Configure the HTTP Request Connector

  1. Create the HTTP Request connector. Provide the ServiceNow username and password in the Authentication tab after selecting Basic from the Protocol dropdown.

  2. Keep the default values in the Pooling Profile and the Reconnection tabs.

  3. Click Validate Config to confirm that the parameters of your global ServiceNow connector are accurate, and that Mule is able to successfully connect to your instance of ServiceNow. See: Testing Connections.

  4. Click OK to save the global connector configurations.

To Configure an Example Using XML Code

To configure the ServiceNow global element:

  1. Ensure you have included the following name spaces in your configuration file:

    http://www.mulesoft.org/schema/mule/servicenow
    http://www.mulesoft.org/schema/mule/servicenow/current/mule-servicenow.xsd
  2. Create a global ServiceNow configuration outside and above your flows, using the following global configuration code:

    <servicenow:config name="ServiceNow_Connector__configuration" username="${servicenow.username}" password="${servicenow.password}" serviceAddress="${servicenow.serviceEndpoint}" doc:name="ServiceNow Connector: configuration">
    Attribute Description

    name

    Enter a name for the configuration with which to reference it.

    username

    Username for connecting to your ServiceNow instance.

    password

    The corresponding password.

    serviceAddress

    The URL of the ServiceNow instance. Format: https://<instancename>.service-now.com

To Add the ServiceNow Connector to a Flow

  1. Create a new Mule project in Anypoint Studio.

  2. Drag the ServiceNow Connector onto the canvas, then select it to open the properties editor.

  3. Configure the connector’s parameters:

    servicenow getkeys config
    Field Description

    Display Name

    Enter a unique label for the connector in your application.

    Connector Configuration

    Select a global ServiceNow connector element from the dropdown.

    Operation

    Invoke

    Table

    Select a ServiceNow table from the dropdown.

    Operation

    Select the operation to perform on the table your select.

  4. Click the blank space on the canvas to save your configurations.

About Use Case Examples

The following are use cases for the ServiceNow connector described in subsequent sections:

Example 1: Get ServiceNow Incident Table Keys

Create a Mule flow to get keys from the Incident table in your ServiceNow instance.

See additional examples at the ServiceNow connector resource page.

servicenow-getkeys-flow
  1. Create a Mule project in your Anypoint Studio.

  2. Drag an HTTP connector into the canvas, then select it to open the properties editor console.

    The HTTP Request configuration sets properties for the HTTP connection: socket properties, proxy settings, and authentication. This simple configuration assumes a default HTTP request configuration. If a different authentication strategy is employed, it can be configured within the advanced configuration of the connector.

  3. Add a new HTTP Listener Configuration global element:

    1. In Connector Configuration, click the green plus button (+).

    2. Accept the default parameters: port 8081 and host 0.0.0.0.

    3. In the HTTP connector properties, set the path to the /get value.

  4. Add a Set Payload transformer after the HTTP connector, and set the value to #[['description': 'Get Keys Demo']]

  5. Search for servicenow and drag the ServiceNow connector after the Set Payload block.

  6. Click the green plus sign next to Connector Configuration, choose ServiceNow: Basic Configuration, and set the username, password, and service address to your ServiceNow access credentials.

  7. Click Validate Config to confirm that Mule can connect with your ServiceNow instance. If the connection is successful, click OK to save the configurations of the global element. If unsuccessful, revise or correct any incorrect parameters, and test again.

  8. In the properties editor of the ServiceNow connector, set the Table to Incident and the Operation to getKeys:

    servicenow getkeys config
  9. Search for dataweave and drag the Transform Message processor between the Set Payload transformer and the ServiceNow connector, and configure it as follows:

    servicenow-dw-keys
  10. The Output properties are automatically configured to correspond to the ServiceNow connector’s input properties.

  11. Add an XML to JSON transformer.

  12. Save and run the project as a Mule Application.

  13. From a browser, navigate to http://0.0.0.0:8081/incident/get

  14. Mule performs the query to get keys from the Incident table and displays them in your browser.

For this code to work in Anypoint Studio, you must provide the credentials for your ServiceNow instance. You can either replace the variables with their values in the code, or you can add a file named mule.properties to the src/main/properties folder to provide the values for each variable.

The XML code for this flow is:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:servicenow="http://www.mulesoft.org/schema/mule/servicenow" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/servicenow http://www.mulesoft.org/schema/mule/servicenow/current/mule-servicenow.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
 <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" basePath="/incident" doc:name="HTTP Listener Configuration"/>
 <servicenow:config name="ServiceNow_Connector_configuration" username="${servicenow.username}" password="${servicenow.password}" serviceAddress="${servicenow.serviceEndpoint}" doc:name="ServiceNow Connector: configuration">
 <servicenow:list-of-user-table>
 </servicenow:list-of-user-table>
 </servicenow:config>

<data-mapper:config name="Map_To_Xml_insert_" transformationGraphPath="map_to_xml_insert_.grf" doc:name="Map_To_Xml_insert_"/>

 <data-mapper:config name="Xml_getKeysResponse_To_JSON" transformationGraphPath="xml_getkeysresponse_to_json.grf" doc:name="Xml_getKeysResponse_To_JSON"/>

<flow name="demo-getkeys-incident">
 <http:listener config-ref="HTTP_Listener_Configuration" path="/getkeys" doc:name="/getkeys"/>
 <set-payload value="#[['description':'TESTWSDLQA']]" doc:name="Set Payload"/>
 <data-mapper:transform config-ref="Map_To_Xml_getKeys_" doc:name="Map To Xml&lt;getKeys&gt;"/>
 <logger message="#[payload]" level="INFO" doc:name="Logger"/>
 <servicenow:invoke config-ref="ServiceNow_Connector_configuration" type="incident||getKeys" doc:name="ServiceNow - GetKeys"/>
 <logger message="#[payload]" level="INFO" doc:name="Logger"/>
 <data-mapper:transform config-ref="Xml_getKeysResponse_To_JSON" doc:name="Xml&lt;getKeysResponse&gt; To JSON"/>
 </flow>

</mule>

Example 2: Get Records from ServiceNow Incident Table

Create a Mule flow to get records from the Incident table.

servicenow 84375
  1. Create a Mule project in your Anypoint Studio.

  2. Drag an HTTP connector into the canvas, and click the green plus sign. Accept the default values.

  3. In the HTTP connector properties view, configure the following HTTP path as getrecords:

  4. Add a Set Payload transformer after the HTTP connector, and configure the value field to: #[['description': 'Get Records Demo']]

  5. Search for servicenow and drag the ServiceNow connector after the Set Payload block.

  6. Click the green plus sign next to Connector Configuration, choose ServiceNow: Basic Configuration, and set the username, password, and service address to your ServiceNow access credentials.

  7. If you haven’t already created a ServiceNow global element, add one by clicking the plus sign next to the Connector Configuration field of the ServiceNow element and select *ServiceNow: Basic Configuration. Click OK.

  8. Click Validate Config to confirm that Mule can connect with your ServiceNow instance. If the connection is successful, click OK to save the configurations of the global element. If unsuccessful, revise or correct any incorrect parameters, then test again.

  9. In the properties editor of the ServiceNow connector, set Table to Incident and Operation to getRecords.

  10. Drag a DataWeave element between the Set Payload transformer and the ServiceNow connector, and configure it as follows:

    servicenow-dw-records
  11. The Output properties are automatically configured to correspond to the ServiceNow connector’s input properties.

  12. Add a Logger component and an XML to JSON transformer after the ServiceNow connector.

  13. Save and Run as Mule Application.

  14. From a browser, navigate to http://0.0.0.0:8081/incident/getrecords

  15. Mule performs the query to retrieve records from the Incident table and displays the response in your browser.

The XML code for this example is:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper"
	xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:datamapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:servicenow="http://www.mulesoft.org/schema/mule/servicenow" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/servicenow http://www.mulesoft.org/schema/mule/servicenow/current/mule-servicenow.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
 <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" basePath="/incident" doc:name="HTTP Listener Configuration"/>
 <servicenow:config name="ServiceNow_Connector_configuration" username="${servicenow.username}" password="${servicenow.password}" serviceAddress="${servicenow.serviceEndpoint}" doc:name="ServiceNow Connector: configuration">
 </servicenow:config>
<flow name="demo-getrecords-incident">
 <http:listener config-ref="HTTP_Listener_Configuration" path="/getrecords" doc:name="/getrecords"/>
        <set-payload value="#[['description':'TESTWSDLQA']]" doc:name="Set Payload"/>
        <dw:transform-message doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 http://www.service-now.com/incident
---
{
	ns0#getRecords: payload.description
}]]></dw:set-payload>
        </dw:transform-message>
 <servicenow:invoke config-ref="ServiceNow_Connector_configuration" type="incident||getRecords" doc:name="ServiceNow - GetRecords"/>
 <logger message="#[payload]" level="INFO" doc:name="Logger"/>
        <json:xml-to-json-transformer doc:name="XML to JSON"/>
 </flow>
 </mule>

See Also