Update the fields in ServiceNow which are being updated in Jira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2022 04:16 AM
I have integrated ServiceNow with Jira. Now my requirement is whenever any field is being updated in Jira, the same should also get reflected in servicenow. For this, I am using Scripted Rest API and created webhook in Jira.
I have written the following script in Scripted Rest API, but it does not works -
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
try {
var requestBody = request.body.data;
gs.log('jiralog '+ requestBody.issue.fields.project.name);
var jr= new GlideRecord('incident');
jr.addQuery('correlation_id',requestBody.issue.key);
jr.query();
if(!jr.next())
{
jr.initialize();
jr.description=requestBody.issue.fields.description;
jr.insert();
gs.log('Jira Issue created: '+jr.correlation_id);
}
else{
jr.description=requestBody.issue.fields.description;
jr.update();
gs.log('Jira Issue updated: '+jr.correlation_id);
}
}
catch(ex) {
var message = ex.message;
}
})(request, response);
Please help me where I am wrong in this script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2022 03:44 AM
Can you try
var jcomments = '';
if (requestBody.fields.comment.comments.length > 0) {
for (var i = 0; i < requestBody.fields.comment.comments.length; i++) {
jcomments = '\n';
jcomments += requestBody.fields.comment.comments[i].body;
jcomments += 'At: ' + requestBody.fields.comment.comments[i].updated;
jcomments += 'Updated By: ' + requestBody.fields.comment.comments[i].updateAuthor.displayName + ' [' + requestBody.fields.comment.comments[i].updateAuthor.emailAddress + ']';
}
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2022 10:12 AM
Hi Shalika
I'm working as a pre-sales engineer with Exalate.
Exalate was designed with exactly these types of use-cases in mind, you could say that it is our "bread and butter".
One of Exalate's features, apart from syncing tickets bi-directionally, is syncing fields from snow to jira.
The entity will out-of-the-box be fully bi-directionally syncronized, which means, if a field gets updated on either side, it will automatically update on the other side, you can change this to make it uni-directional if you so please.
Exalate is easy and straightforward to set-up and you can control exactly which data you want to send and/or receive.
If you would like to see a customized demo of the product, please book a slot.
Cheers