ServiceNow to Jira integration using business rule

Shalika
Tera Expert

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 

12 REPLIES 12

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.

Regards,
Nagaraj Tofin

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?

Eric Smith
Tera Expert

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.