This project is a microservice for managing incidents in SerivceNow. When an alarm in Cumulocity is created the microservice creates a resulting incident. When the incident is resolved the corresponing alarm in Cumulocity is cleared. This allows to work in an efficient manner in a IT Service Management Platform ServiceNow and link it to Cumulocity. Potential use cases are:
- Extend IT Service Management and Help Desk in cumulocity
For this demo a Cumulocity tenant and a ServiceNow instance are required. For a free trial tenant you can register here.
The microservice is written in NodeJS. New Cumulocity alarms generate incidents in ServiceNow. When the incident is resolved the correponding Cumulocity alarm is cleared.
- Clone git repository
git clone https://github.com/SoftwareAG/cumulocity-microservice-servicenow.git
- Update proerties in
.env
The following properties in .env
have to updated afetr you created a ServiceNow instance.
SERVICENOW_USER=***
SERVICENOW_PASSWORD=***
SERVICENOW_INSTANCENAME=***
Before you deploy the microservice you have to download the script microservice
from here. Further documentation is available on the Cumulocity Developer Site.
In order to deploy the microservice run:
$ cd docker
$ microservice pack deploy subscribe -n node-ms-servicenow -u <CUMULOCITY_USER> -p <CUMULOCITY_PASSWORD> -te <CUMULOCITY_TENANT> -d "https://<CUMULOCITY_TENANT>.eu-latest.cumulocity.com"
-
Login to ServiceNow instance, open
Business Rules
, in Left Navigation -
Create new Business Rule
Call Cumulocity
- Enter setting as marked on screenshot
- Choose Table -> Incident
- Advanced -> checked
- On tab When to run -> after, Update
- On tab Advanced copy the following code:
(function executeRule(current, previous /*null when async*/) {
try {
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://<CUMULOCITY_TENANT>.cumulocity.com/service/node-ms-servicenow/incident');
request.setHttpMethod('POST');
var user = "***";
var password = "***";
var string = {};
request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
string.u_short_description = current.getValue('short_description');
string.u_impact = current.getValue('impact');
string.u_urgency = current.getValue('urgency');
string.u_state = current.getValue('state');
string.u_number = current.getValue('number');
var u_updated_by = current.getValue('sys_updated_by');
string.u_updated_on = current.getValue('sys_updated_on');
string.u_updated_name = (' ' + resolveName(u_updated_by)).slice(1);
var myJSON = JSON.stringify(string);
request.setRequestHeader('Content-Type','application/json');
request.setRequestBody(myJSON);
var response = request.execute();
gs.log('test: '+response.getBody());
} catch(err) {
gs.log('Orange Error: ' + err);
}
})(current, previous);
function resolveName (updated_by) {
var gr = new GlideRecord('sys_user');
gr.addQuery('user_name', updated_by);
gr.query();
if(gr.next()) {
return gr.first_name;
}
}
- Create alarm in Cumulocity
- Resolve corresponding incident in ServiceNow
- View cleared alarm in Cumulocity
These tools are provided as-is and without warranty or support. They do not constitute part of the Software AG product suite. Users are free to use, fork and modify them, subject to the license agreement. While Software AG welcomes contributions, we cannot guarantee to include every contribution in the master project.
For more information you can Ask a Question in the TECHcommunity Forums.
You can find additional information in the Software AG TECHcommunity.
Contact us at TECHcommunity if you have any questions.