Send comments and worknotes from servicenow to jira

Shalika
Tera Expert

I have integrated servicenow and jira. I want to send the comments and work notes from servicenow to jira.

The Business rule which I have written is 

(function executeRule(current, previous /*null when async*/) {

try { 
 var r = new sn_ws.RESTMessageV2('Neste Siili JIRA', 'PUT');
    r.setEndpoint('https://neste-jira.atlassian.net/rest/api/3/issue/'+current.correlation_id);
 
  r.setStringParameter("description",current.description);
    r.setStringParameter("summary",current.number+'  '+current.short_description);

if(current.priority == "1")
            {
                r.setStringParameter("priority","Critical");
            }
    if(current.priority == "2")
            {
                r.setStringParameter("priority","Major");
            }
    if(current.priority == "3" || current.priority == "4")
            {
                r.setStringParameter("priority","Minor");
            }


 var response = r.execute();
 var responseBody = response.getBody();
 var httpStatus = response.getStatusCode();
    gs.log("put body jira"+responseBody);
    gs.log("put status "+httpStatus);
}
catch(ex) {
 var message = ex.message;
}
 })(current, previous);

 

What else I need to add in my business rule for sending comments 

4 REPLIES 4

Marcin20
Mega Guru

Hi,

 

To retrieve comments / worknotes (i.e. from the incident record) I propose to use the getJournalEntry()

https://developer.servicenow.com/dev.do#!/reference/api/sandiego/server_legacy/c_GlideElementAPI#r_G...

 

The example in the above link refers to the work notes,

this line will get comments:

 

var comments= current.comments.getJournalEntry(-1); 

 

Best Regards,

Marcin

 

 

If my answer helped you in any way, please mark this answer as helpful and correct.

Hello,

I am sending the payload as follows -

 

 

I am getting the error in response as in above screenshot.

How to resolve this issue?

Hello,

I am sending the payload as attached in the attachment 

I am getting the error in response as in above screenshot.

How to resolve this issue?

Hello,

Please could you give us more details, to which system do you send it?

Which endpoint is used?

 

Best Regards.

Marcin