Comment not updating from Jira to ServiceNow Incident using Scripted REST API

surbhi_123
Tera Expert

I have integrated snow and jira and to update the comments in snow from jira I am using scripted rest api.

The logs which I am recieving is as follows -

{"comment":[{"id":"11705","key":"SSP-9504","user":"Prajwal Ashok Nagrale","body":"Sent to SErvice"}]}

 

var requestBody = request.body.data;
var body = JSON.stringify(request.body.data);
var parser = new JSONParser();
var parameterArr = parser.parse(body);
var jr = new GlideRecord('incident');

jr.addQuery('correlation_id', comment.key);
jr.query();
if (jr.next()) {

var JiraComment = parameterArr.comment.body;

jr.work_notes = 'Commented by: ' + parameterArr.comment.user + '\nComment: ' +JiraComment;

jr.update();

}

But this is not updating anything in incident table work notes.

 

Where am I wrong in this ?Please help

1 ACCEPTED SOLUTION

Tony Chatfield1
Kilo Patron

Hi, this is the second time you have posted this question\issue within 24 hours.
The earlier post probably received no reply as it contains no clear details of your configuration or diagnostics\debugging.
Are you updated Incident directly, or are you posting to an import table direct or via scripted rest API?
What are the results of your debugging, in the other post you imply that the body is not extracted from the payload but do not make this clear. Perhaps you could provide some clear and specific details regarding your configuration and diagnostics?

 

EDIT

Have you checked to see if your existing glide query retruins a record for jr.addQuery('correlation_id', comment.key);
Your payload seems to show 'Comment' is an array so perhaps this needs to be allowed for IE

parameterArr.comment[0].key

parameterArr.comment[0].body

 

 

Also, it is unnecessary to post the same question multiple times and if anything is less likely to result in a clear and complete answer to your issue.

 

View solution in original post

2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, this is the second time you have posted this question\issue within 24 hours.
The earlier post probably received no reply as it contains no clear details of your configuration or diagnostics\debugging.
Are you updated Incident directly, or are you posting to an import table direct or via scripted rest API?
What are the results of your debugging, in the other post you imply that the body is not extracted from the payload but do not make this clear. Perhaps you could provide some clear and specific details regarding your configuration and diagnostics?

 

EDIT

Have you checked to see if your existing glide query retruins a record for jr.addQuery('correlation_id', comment.key);
Your payload seems to show 'Comment' is an array so perhaps this needs to be allowed for IE

parameterArr.comment[0].key

parameterArr.comment[0].body

 

 

Also, it is unnecessary to post the same question multiple times and if anything is less likely to result in a clear and complete answer to your issue.

 

I am updating the incident table directly, there is no import set table