ServiceNow Connector 5.x

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.

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, and Istanbul (default)

The ServiceNow connector has been tested with the Eureka, Fuji, Geneva, Helsinki, and Istanbul (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

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

Click Login in Anypoint Exchange.

Search for the connector and click Install.

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 Create a New Project

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

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

Click Finish to create the project.

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

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

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

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:

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).

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

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.

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.

To Configure the HTTP Request Connector

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

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

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.

Click OK to save the global connector configurations.

To Configure an Example Using XML Code

To configure the ServiceNow global element:

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

Example 1: Get ServiceNow Incident Table Keys

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.

Add a new HTTP Listener Configuration global element:

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

Accept the default parameters: port 8081 and host 0.0.0.0.

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

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

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

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.

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.

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

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

The Output properties are automatically configured to correspond to the ServiceNow connector’s input properties.

Add an XML to JSON transformer.

Save and run the project as a Mule Application.

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

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.

Example 2: Get Records from ServiceNow Incident Table

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

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

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

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

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.

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.

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.

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

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

The Output properties are automatically configured to correspond to the ServiceNow connector’s input properties.

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

Save and Run as Mule Application.

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

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