Select
The ServiceNow Connector facilitates connections between Mule integration and ServiceNow applications. The ServiceNow Connector v5 allows you to perform seven standard operations (insert, update, get, getKeys, getRecords, deleteMultiple, deleteRecord) on standard as well as the custom ServiceNow tables, along with any operations available through the installed plugins.
Release Notes: ServiceNow Connector Release Notes.
Migration Guide: ServiceNow Connector 5.x Migration Guide.
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.
This document describes implementation examples within the context of Anypoint Studio, Mule ESB’s graphical user interface, and, also includes configuration details for doing the same in the XML Editor.
Compatibility
The latest version of the ServiceNow connector, presently v5.3.0 released September 2016, is compatible with:
Application/Service | Version |
---|---|
Mule Runtime |
3.7.0 or later |
ServiceNow |
Eureka, Fuji, Geneva, Helsinki and Istanbul |
The ServiceNow connector has been tested with the Eureka, Fuji, Geneva, Helsinki and Istanbul 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 connector is not compatible with Mule runtimes prior to 3.7. |
Installing and Configuring
Installing
You can install a connector in Anypoint Studio using the instructions in Installing a Connector from Anypoint Exchange.
However, 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 either of these. (Read more about Installing an Enterprise License.)
Creating a New Project
To use the ServiceNow connector in a Mule application project:
-
In Studio, select File > New > Mule 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 then click Next.
-
Click Finish to create the project.
Configuring the Global Element
To use the ServiceNow Connector in your Mule application, you must configure a global ServiceNow element that can be used by all the ServiceNow connectors in the application (read more about global elements). The ServiceNow connector supports a simple configuration and an advanced configuration.
ServiceNow API relies on HTTP Basic authentication which is the default authentication system to make an HTTP request. The HTTP Request configuration establishes various properties for the HTTP connection: socket properties, proxy settings and even various authentication mechanisms. 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.
[tab,title="Studio Visual Editor"] .... Follow these steps to create a ServiceNow global element: . Click the *Global Elements* tab at the base of the canvas. . On the Global Mule Configuration Elements screen, click *Create*. . In the Choose Global Type wizard, expand *Connector Configuration*, and click *ServiceNow: Advanced* or *ServiceNow: Basic*, depending on your ServiceNow implementation. + image:servicenow-choose-global-type.png[servicenow-choose-global-type] + . Click *OK* . Enter the global element properties: .. For *ServiceNow Connector: Basic Configuration*: + image:servicenow-config.png[servicenow-config] + [width="100a",cols="50a,50a",options="header"] |=== |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 the ServiceNow instance. Format: `https://<instancename>.service-now.com` |*ServiceNow Version* |Select the version of your ServiceNow instance. |*User Table List* | * *None* - DataSense does not fetch any user tables. * *Create Object manually* - A user creates a list and adds the table names to the list - only those user tables are acquired by DataSense. |=== + [NOTE] In the image above, the placeholder values refer to a configuration file placed in the `src` folder of your project (link:/mule-user-guide/v/3.7/configuring-properties[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, Mule recommends that you 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 link:/mule-user-guide/v/3.7/deploying-to-multiple-environments[Deploying to Multiple Environments] for instructions on how to manage this. + . For *ServiceNow Connector: Advanced Configuration*: + image:servicenow-advanced-config.png[servicenow-advanced-config] + [width="100a",cols="50a,50a",options="header"] |=== |Field |Description |*Name* |Enter a name for the configuration. |*HTTP Request Config* |Enter an HTTP Request configuration. |*Service Address* |The URL of the ServiceNow instance. Format: `https://<instancename>.service-now.com` |*ServiceNow Version* |Select the version of your ServiceNow instance. |*User Table List* | * *None* - DataSense does not fetch any user tables. * *Create Object manually* - A user creates a list and adds the table names to the list - only those user tables are acquired by DataSense. |=== + image:servicenow-advanced-basic-auth.png[servicenow-advanced-basic-auth] + . Create the HTTP Request Config object. 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. Read more about link:/mule-user-guide/v/3.7/testing-connections[Testing Connections]. . Click *OK* to save the global connector configurations. .... [tab,title="XML Editor"] .... To configure the ServiceNow global element: . Ensure you have included the following namespaces in your configuration file: + [source, code, linenums] ---- http://www.mulesoft.org/schema/mule/servicenow http://www.mulesoft.org/schema/mule/servicenow/current/mule-servicenow.xsd ---- + . Create a global ServiceNow configuration outside and above your flows, using the following global configuration code: + [source, xml, linenums] ---- <servicenow:config name="ServiceNow_Connector__configuration" username="${servicenow.username}" password="${servicenow.password}" serviceAddress="${servicenow.serviceEndpoint}" doc:name="ServiceNow Connector: configuration"> ---- + [width="100a",cols="50a,50a",options="header"] |=== |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` |=== ....
Using the Connector
ServiceNow connector is an operation-based connector, which means that when you add the connector to your flow, you need to configure a specific operation (Invoke operation) for the connector to perform. The XML element for the Invoke operation is servicenow-wsdl:invoke. After you call the Invoke operation, you can use the "Table" and "Operation" fields to select a method you want to execute on a particular ServiceNow table. The ServiceNow connector v5 allows you to perform seven standard operations (insert, update, get, getKeys, getRecords, deleteMultiple, deleteRecord) on the standard as well as custom ServiceNow tables, along with any operations available through the installed plugins.
Use Cases
Below are a few common use cases for the ServiceNow connector:
-
Get Records from the Incident table.
-
Get Keys from the Incident table.
-
Update Incident table using the new DataWeave Language.
Adding the ServiceNow Connector to a Flow
-
Create a new Mule project in Anypoint Studio.
-
Drag the ServiceNow Connector onto the canvas, then select it to open the properties editor.
-
Configure the connector’s parameters:
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.
-
Click the blank space on the canvas to save your configurations.
Example Use Case - Get ServiceNow Incident Table Keys
Create a Mule flow to get keys from the Incident table in your ServiceNow instance.
[tab,title="Studio Visual Editor"] .... image:servicenow-getkeys-flow.jpg[servicenow-getkeys-flow] . Create a Mule project in your Anypoint Studio. . Drag an HTTP connector into the canvas, then select it to open the properties editor console. . Add a new HTTP Listener Configuration global element: .. In *Connector Configuration*, click the green plus button (*+*): + image:servicenow-http-conn-cfg.png[servicenow-http-conn-cfg] + .. Configure the following HTTP parameters: + image:servicenow-http-listener-cfg.png[servicenow-http-listener-cfg] + [width="100a",cols="50a,50a",options="header"] |=== |Field |Value |*Port* |8081 |*Host* |localhost |*Display Name* |HTTP_Listener_Configuration |=== + .. Reference the HTTP Listener Configuration global element: + image:servicenow_get.png[servicenow_get] + . Add a Set Payload transformer after the HTTP connector, and configure it as follows: + [width="100a",cols="50a,50a",options="header"] |=== |Field |Value |*Display Name* |Enter a name of your choice. |*Value* |#[['description': 'Get Keys Demo']] |=== + . Drag a ServiceNow connector into the flow to create a ServiceNow user with the message payload. . If you haven't already created a ServiceNow global element, add one by clicking the plus sign next to the *Connector Configuration* field. Select *ServiceNow: Basic Configuration* and click *OK*. . Configure the global element: + image:servicenow-config.png[servicenow-config] + [width="100a",cols="50a,50a",options="header"] |=== |Field |Description |*Name* |Enter a unique label for this global element to be referenced by connectors in the flow. |*Username* |Enter a Username for connecting to the ServiceNow instance. |*Password* |Enter the user password. |*ServiceNow Address* |Enter the URL of your ServiceNow server. + The format of the ServiceNow URL is: `https://<instancename>.service-now.com` |=== + . 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. . Back in the properties editor of the ServiceNow connector, configure the remaining parameters: + image:servicenow-getkeys-config.png[servicenow-getkeys-config] + [width="100a",cols="50a,50a",options="header"] |=== |Field |Value |*Display Name* |ServiceNow - GetKeys (or any other name you prefer) |*Config Reference* |Enter name of the global element you have created |*Operation* |Invoke |*Table* |Incident |*Operation* |getKeys |=== + . Drag a DataMapper transformer between the Set Payload transformer and the ServiceNow connector, then configure it as follows: + image:servicenow-datamapper.png[servicenow-datamapper] + . The Output properties are automatically configured to correspond to the ServiceNow connector's input properties. . Click *Create Mapping.* . Add another DataMapper after the ServiceNow connector to map connector's response into JSON. . Save and run the project as a Mule Application. . From a browser, navigate to `http://localhost:8081/get` . Mule performs the query to get keys from the Incident table and displays them in the browser. .... [tab,title="XML Editor"] .... [NOTE] For this code to work in Anypoint Studio, you must provide the credentials for the ServiceNow instance. You can either replace the variables with their values in the code, or you can add a file named `mule.properties` in the `src/main/properties` folder to provide the values for each variable. [source,xml,linenums] ---- <?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" version="EE-3.7.0" 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<getKeys>"/> <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<getKeysResponse> To JSON"/> </flow> </mule> ---- ....
Example Use Case - Get Records from ServiceNow Incident Table
Create a Mule flow to get records from the Incident table.
[tab,title="Studio Visual Editor"] .... image:servicenow-get-records-flow.jpg[servicenow-get-records-flow] . Create a Mule project in your Anypoint Studio. . Drag an HTTP connector into the canvas, then select it to open the properties editor console. . Add a new HTTP Listener Configuration global element: .. In *Connector Configurations*, click the green plus *+* button: + image:servicenow-http-conn-cfg.png[servicenow-http-conn-cfg] + .. Configure the following HTTP parameters: + image:servicenow-http-get-records.png[servicenow-http-get-records] + . Add a Set Payload transformer after the HTTP connector, and configure it as follows: + [width="100a",cols="50a,50a",options="header"] |=== |Field |Value |*Display Name* |Enter a name of your choice. |*Value* |#[['description': 'Get Records Demo']] |=== + . Drag a ServiceNow connector into the flow to create a ServiceNow user with the message payload. . If you haven't already crated a ServiceNow global element, add one by clicking the plus *+* sign next to the *Connector Configuration* field. Select *ServiceNow: Basic Configuration* and click *OK*. . Configure the global element: + image:servicenow-config.png[servicenow-config] + [width="100a",cols="50a,50a",options="header"] |=== |Field |Description |*Name* |Enter a unique label for this global element to be referenced by connectors in the flow. |*Username* |Enter a Username for connecting to the ServiceNow instance. |*Password* |Enter the user password. |*ServiceNow Address* |Enter the URL of your ServiceNow server. + The format of the ServiceNow URL is: `https://<instancename>.service-now.com` |=== + . 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. . Back in the properties editor of the ServiceNow connector, configure the remaining parameters: + image:servicenow-get-records-configuration.png[servicenow-get-records-configuration] + [width="100a",cols="50a,50a",options="header"] |=== |Field |Value |*Display Name* |getRecords (or any other name you prefer). |*Config Reference* |Enter the name of the global element you have created. |*Operation* |Invoke |*Table* |Incident |*Operation* |getRecords |=== + . Drag a DataMapper transformer between the Set Payload transformer and the ServiceNow connector, then configure it as follows: + image:servicenow-demo2-datamapper.png[servicenow-demo2-datamapper] + . The Output properties are automatically configured to correspond to the ServiceNow connector's input properties. . Click *Create Mapping.* . Add another DataMapper after the ServiceNow connector to map the connector's response into JSON. . Save and run the project as a Mule Application. . From a browser, navigate to `http://localhost:8081/getrecords.` . Mule performs the query to retrieve records from the Incident table and displays them in the browser. .... [tab,title="XML Editor"] .... [NOTE] For this code to work in Anypoint Studio, you must provide the credentials for the 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. [source,xml,linenums] ---- <?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: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" version="EE-3.7.0" 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_getRecordsResponse_To_JSON" transformationGraphPath="xml_getrecordsresponse_to_json.grf" doc:name="Xml_getRecordsResponse_To_JSON"/> <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"/> <data-mapper:transform config-ref="Map_To_Xml_getRecords_" doc:name="Map To Xml<getRecords>"/> <servicenow:invoke config-ref="ServiceNow_Connector_configuration" type="incident||getRecords" doc:name="ServiceNow - GetRecords"/> <logger message="#[payload]" level="INFO" doc:name="Logger"/> <data-mapper:transform config-ref="Xml_getRecordsResponse_To_JSON" doc:name="Xml<getRecordsResponse> To JSON"/> </flow> </mule> ---- ....
See Also
-
Learn more about working with Anypoint Connectors.