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

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3L-pRlJHGOLNs9WYV%2F-MV3Ra93DZoB09mrQzCe%2FScreen%20Shot%202021-03-05%20at%202.10.53%20PM.png?alt=media\&token=1f49f8cd-fd63-4cc6-99e3-84ce031c108b)

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

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3L-pRlJHGOLNs9WYV%2F-MV3S9pDqGu34uT1gRKC%2FScreen%20Shot%202021-03-05%20at%202.14.00%20PM.png?alt=media\&token=79072331-fab8-4f25-bf81-a205408afdf6)

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

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3SsO9EkWTA2guKFBE%2F-MV3TRxybtIbBBhin9Cp%2FScreen%20Shot%202021-03-05%20at%202.19.41%20PM.png?alt=media\&token=fb2df18a-e6d5-4eba-9973-3af0811b3425)

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

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3TYhII6kNRH3iSlaa%2F-MV3W37BmeMeTLsMeb-9%2FScreen%20Shot%202021-03-05%20at%202.30.54%20PM.png?alt=media\&token=24c6d5ba-8c1d-4e5e-abbc-e12700844aae)

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

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3TYhII6kNRH3iSlaa%2F-MV3XorlvIpquP7LE5ZT%2FScreen%20Shot%202021-03-05%20at%202.37.28%20PM.png?alt=media\&token=018f29a9-1462-4a8f-b9c1-1d70688a14e1)

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3TYhII6kNRH3iSlaa%2F-MV3Y4BrF9lAL43KMm0l%2FScreen%20Shot%202021-03-05%20at%202.39.56%20PM.png?alt=media\&token=dffc5ec2-e26c-4bba-9777-5f7dae175e97)

**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**'

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3Zig9WPxarY3DuF8l%2F-MV3t93BXI3cYCWJSvWe%2FScreen%20Shot%202021-03-05%20at%204.16.20%20PM.png?alt=media\&token=16125d2d-2340-411e-a4d9-a22b888b82c2)

{% 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.

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3ywN09QRjgElfy6y6%2F-MV40wDfApCguJTHNaw0%2FScreen%20Shot%202021-03-05%20at%204.54.43%20PM.png?alt=media\&token=09a21c14-1dba-4d85-90c2-4c2c1a0eb1c5)

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

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3ywN09QRjgElfy6y6%2F-MV41yhXmqTMoVgujK8x%2FScreen%20Shot%202021-03-05%20at%204.58.41%20PM.png?alt=media\&token=3d1cce03-20a7-486d-808d-e09c0bb819a8)

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

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3ywN09QRjgElfy6y6%2F-MV42jSvu7_v5wR81SIn%2FScreen%20Shot%202021-03-05%20at%205.02.37%20PM.png?alt=media\&token=7b982abd-3c4a-463c-b420-461fcdf05f01)

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

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3ywN09QRjgElfy6y6%2F-MV43QLzVyuwR9DqFS0s%2FScreen%20Shot%202021-03-05%20at%205.05.20%20PM.png?alt=media\&token=68d34636-22d1-4f54-899d-b4d4232d1c83)

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

![](https://4260296531-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAygHzNCQ33zRR43qxF%2F-MV3ywN09QRjgElfy6y6%2F-MV45Qc7K1kf40gSwzT8%2FScreen%20Shot%202021-03-05%20at%205.14.23%20PM.png?alt=media\&token=e9910cca-8b78-45e3-a66f-34e2c4f25276)

### 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
