ServiceNow to Jira integration using business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2022 11:20 PM
I am new to integration in ServiceNow.
I want to integrate SNow and Jira. The use case is such that whenever a incident is created in SNow, it should reflect in Jira. I have created the REST message Successfully. After that, what I need to do?
Should I write a business rule and if yes what would it be like
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 02:13 AM
Hi Shalika,
Please find below code snippet to be written in script include function about creation of payload in JSON format.
Var grIncident = new GlideRecord('incident');
grIncident.addEncodedQuery('sys_id='+grIncident.getUniqueValue());
grIncident.query();
if(grIncident.next()) {
var data = {};
data = {
'short_description': grIncident.short_description,
'number': grIncident.number
}
var payload = JSON.stringify(data);
}
Kindly mark as correct if I answered or provided solution for your query.
Nagaraj Tofin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 01:06 AM
I have created BR as follows -
try{
sm = new sn_ws.RESTMessageV2("Neste Siili JIRA", "POST");
sm.setStringParameter("description", current.description);
sm.setStringParameter("short_description", current.short_description);
sm.setStringParameter("number", current.number);
var payload ='';
payload+= payload + "1" + current.description + "2" + current.short_description + "3" + current.number;
gs.log("hello INC Silli "+ payload);
response = sm.execute();
status = response.getStatusCode();
} catch(ex) {
responseBody = ex.getMessage();
status = '500';
gs.log("hello JIRA response"+responseBody );
} finally {
requestBody = sm ? sm.getRequestBody():null;
}
}
And created POST method with payload contents as follows -
{
"fields": {
"project": {
"key": "SSP"
},
"short description": "${short_description}",
"description": "${description}",
"issuetype": {
"name": "Incident"
}
}
}
I can see the response code as 200, but still no issue being created on Jira side
What am I doing wrong here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 11:06 AM
Shalika, hi. I think Nagaraj pointed out the solution. I must admit we do use external help to make such integration. We deploy a connector (called zigiops) - it saves a lot of time and effort and works great.