> For the complete documentation index, see [llms.txt](https://oiadocs.cloudfabrix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oiadocs.cloudfabrix.io/integrations-guide/integrations/servicenow-as-datasource.md).

# ServiceNow

## Prerequisites: <a href="#prerequisites" id="prerequisites"></a>

ServiceNow provides many modules and features for IT operations and within that CloudFabrix AIOPs platform integrates with Ticketing and CMDB modules.&#x20;

ServiceNow integration is an out of the box in bi-directional way feature by using both APIs and REST message notifications.&#x20;

This document explains step by step on how to integrate CloudFabrix AIOps platform with ServiceNow.&#x20;

### Create ServiceNow User for API access:

**Step 1:** Login to ServiceNow instane portal with an user account which has enough privileges to create a new user and assign required permissions.

![](/files/-MV3Ra93DZoB09mrQzCe)

**Step 2:** Click on '**User Administration**'

![](/files/-MV3S9pDqGu34uT1gRKC)

**Step 3:** Click on '**Users**' and Click on '**New**' to create a new user.

![](/files/-MV3TRxybtIbBBhin9Cp)

**Step 4**: Enter username under '**User ID**', and fill in the details as shown in the below screen. Please make sure to select '**Web service access only**' as this user account is only for API integration.

![](/files/-MV3W37BmeMeTLsMeb-9)

**Step 5**: After creating the user in the above step, edit the user settings to assign appropriate roles and permissions for ServiceNow ticket management and CMDB data read-only access.

![](/files/-MV3XorlvIpquP7LE5ZT)

![](/files/-MV3Y4BrF9lAL43KMm0l)

**Step 6**: Under '**Collection**', search for the highlighted roles and add them to the '**Roles List**' as shown in the below screen and click on '**Save**'

![](/files/-MV3t93BXI3cYCWJSvWe)

{% hint style="info" %}
Notes: Make sure '**Allow access to this table via web services**' option is selected under 'Tables' section of ServiceNow for incident, incident task, change\_request and applicable CMDB tables.
{% endhint %}

### **Configure ServiceNow integration in CloudFabrix AIOps:**&#x20;

**Step 1**: Login into CloudFabrix AIOps UI as an project admin user.

![](/files/-MV40wDfApCguJTHNaw0)

**Step 2**: Click on '**Ops Intelligence & Analytics**' application.

![](/files/-MV41yhXmqTMoVgujK8x)

**Step 3**: Select '**Configure Project**' as shown in the below screen.

![](/files/-MV42jSvu7_v5wR81SIn)

**Step 4**: Click on '**Datasources**' on left menu and click on **+** to add ServiceNow API integration account.

![](/files/-MV43QLzVyuwR9DqFS0s)

**Step 5**: Enter '**Datasource Name**' , '**Description**' and select '**ServiceNow**' under '**Select Datastore Type**' list.

Under '**Domain**' enter ServiceNow instance URL as shown in the screen. Enter '**Username**',  '**Password**' and click on '**Test Connectivity**'. Once successful, click on '**Save**' to save the configuration.

![](/files/-MV45Qc7K1kf40gSwzT8)

### Create Webhook Target for cfxOIA

cfxOIA can ingest and also push the incidents and its status. In order to make the bi-directional flow, both source and target endpoints needs to be created for Incidents.

**Step 1:** Login to cfxDimensions through web-browser UI (as Project Admin user)

**Step 2:** Click on ‘OIA (Ops Intelligence & Analytics)’ application.

**Step 3:** On context menu of existing Project, click on 'Configure Project'.

**Step 4**: Click on Incidents.

**Step 5**: Click on '+' to add new Incident Endpoint.

**Step 6**: Select Endpoint Role as 'Target' and enter Name and Description.

**Step 7**: Select 'Default ServiceNow Ticket' as Event Type.

**Step 8**: Select 'MACAW Notification' as Endpoint type.

**Step 9**: Enter 'NEW\_TICKETS' as Notification ID.

**Step 10**: Click 'Save'

**Step 11**: On the context menu of newly created target incident endpoint, click on 'Enable' to activate the target.

### Configure ServiceNow SaaS for Outbound Incidents

**Step 1**: Login to SNOW instance (ServiceNow Instance)

**Step 2**: Create Rest Outbound by search Rest message.

![](https://lh6.googleusercontent.com/abeFMpm7TxdApocdQaAvykfdYCL7s-vhS1Uv3R1-SXH0sG6pUt6Yv11mctE-QKgXWNiSVVt21mUR5UKaA7dgVDhlAqfFwnViC25EMwTLAHgzdT1VMM9K2egg4gwkyfkpDb7z6nX4)

**Step 3**: Enter the webhook url and authentication details

![](https://lh5.googleusercontent.com/N9gWuTyW7lCQV6vkvrfPdUH4N7MObKD564gRQGJe4mSAgXwaAn9HV9eMk4hFpw_TuA4-MhbklnQEz-AS43QL7JPEkgWHBXuH1zTot1lwtSUfIJekyCQtTrUB8axwQJIFj9PD3VzH)

Step 4: Create "POST" request and define variables, POST, endpoint and authentication.

![](https://lh5.googleusercontent.com/E8sYLnOU6wcbnf4DZNX1Rl8L1NZlIqq9-qfhnFhL0aKQcoGMlNp5la1HHiDbFNwTKHgFzD19O5-1euXAfQqfWuwq8zX6_zbqAjE7dIwKXYxNpq30sgYQ1BxPvTKhIrhLGw5WWrQC)

**Step 5**: Define JSON message structure using the variable defined. Here, we are sending the entire JSON to the webhook.

![](https://lh3.googleusercontent.com/XhK4NhlXJggelCQd25pVDcpc2PLXD-nmUvFmFrJ1N3gFl1edl_Idp3HWnu77TBPCx0GQr8tqDF3zdotY_mdQsEVbBhqoTVGv_t6R8G6krnzfc-At3K_zSeUZrHgcwB1M_c70FwbK)

**Step 6**: Go to System and click on 'Business Rule'

**Step 7**: Create new business rule. Define 'When to Run'

![](https://lh5.googleusercontent.com/NI_4ylJY2Q02oCbz2zWEuWRym_-fqtbTOsZcZPm2yUNHluKSrNCBzYSWvz9JISothMfjCFVpG8lQvAsbtbfUk7i0QW8agi3GdqFrjChrarWX439BCq4hKpJGehEDAiMze0OwFy4j)

**Step 8**: Define "Actions"

![](https://lh5.googleusercontent.com/ZsT8iUsz3-vMTHpja0CM9ZZw20Go2b8fqm_6g-RxTH55IIQ2xXMrrI8MJUphNwZrSnEIWRMWD4yh54I9Wi59fC8j3HQjHKHbvuGD6yZXGpRIqcIEQDRBCEv7_LvY36AeO2Yd9lwF)

**Step 9**: Define "Advanced"

![](https://lh3.googleusercontent.com/aRvIs1nW6-JQ0BPFDGM_2w1bXdX2ixZvAno8Zhgj3MdMpC-eLdr1-zJ_oAHsJ8g6eroQtXWpU-1ez4BYnVLqzaDNrruA93TFKNXZqv_Xj3Wew5EZOkGOxQKiYq5S1QPiGRqZ4C7l)

**Step 10**: Sample Code is given for your reference

```
var JSONG = Class.create();

JSONG.prototype = Object.extendsObject(JSON, {
	encodeGr : function(o) {
		var a = ["{"], b, i, v;
			
			for (i in o) {
				if(o.hasOwnProperty(i)) {
					v = o[i].toString();
					
					switch (typeof v) {
						case "undefined":
						case "function":
						case "unknown":
						break;
						default:
						if (b) {
							a.push(',');
}
						a.push(this.encode(i), ":", v === null ? "null" : this.encode(v));
						b = true;
					}
				}
			}
			
			a.push("}");
			return a.join("");
		}
	});
	
	(function executeRule(current, previous /*null when async*/) {
		var r = new sn_ws.RESTMessageV2('CFX-SVCNOW-WEBHOOK', 'post');
		var parser = new JSONG();
		var data = parser.encodeGr(current);
		r.setRequestBody(data);
		var response = r.execute();
		var responseBody = response.getBody();
		var httpStatus = response.getStatusCode();
	})(current, previous);

```

**Step 11**: Update / Create an incident and check on CloudFabrix side  and check if the incident is created in the incidents UI on cfxOIA
