When incident is created in service now the Bug should be created in azure devops

sahana hattikal
Tera Contributor

Hi Team,

I have requirement to generate workitem id in azue devops  when incident is created in service now . I have set up the connection and created rest message and business rule for the same still it's not working . Can anyone please help on this how to achieve this req. If i click test from rest message id is creating in azure devops but not from incident.

Please find the below rest message:

 

 

 

Business rule :Before update

try {

        var Assignment = current.assignment_group;
        var work_type = '';
        var work_id = current.u_work_item;
        var projectName = current.u_projectname;
        var task_descrpt = current.short_description;
        var incno = current.incident.number;
    
   
        if (Assignment !== '') { 
            work_type = '$Bug';
        }
        var inc = new GlideRecord('incident');
        inc.addQuery('sys_id', current.incident);
        inc.query();

         var restep = task_descrpt + incno;

        var r = new sn_ws.RESTMessageV2('Devops', 'POST');
        r.setStringParameter('Project', projectName);
        r.setStringParameter('type', work_type);
        r.setStringParameter('title', task_descrpt);
        r.setStringParameter('IncidentItem', incno);
        r.setStringParameter('reprosteps', restep);
      
       

        var response = r.execute();

        var responseBody = response.getBody();

        var httpStatus = response.getStatusCode();

        var getResp = JSON.parse(responseBody);

        var authCode = getResp.token;

        if (httpStatus == 200) {
            current.work_notes = 'Work Item successfully created.';
            current.u_work_item = getResp.id;
        } else {
            current.work_notes = "Work Item was not created in Azure DevOps, please check the Project Name and enter the correct name.";
        }

    } catch (ex) {

        var message = ex.getMessage();

    }

    try {

        var br = new sn_ws.RESTMessageV2('Devops', 'GET');
        br.setStringParameter('project', projectName);
        br.setStringParameter('id', work_id);

        response = br.execute();

        responseBody = response.getBody();

        httpStatus = response.getStatusCode();

        getResp = JSON.parse(responseBody);

        authCode = getResp.token;
        if (httpStatus == 200) {
            current.work_notes = 'Work Id created is:' + work_id;
        }

    } catch (ex) {

        message = ex.getMessage();

    }
})(current, previous);

 

 

 

6 REPLIES 6

Mathieu Lepoutr
Mega Guru

Hi @sahana hattikal 

I'm working as a pre-sales engineer with Exalate.

May I suggest you have a look at our decentralized solution please; it has the capability to syncronize all entity types between SNOW and Azure Devops.

This includes generating the workitem id in azue devops when an incident is created in service now.

 

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

Shreya Shah
ServiceNow Employee
ServiceNow Employee

Use Flow Designer to trigger actions on Microsoft Azure DevOps using various actions available in the Microsoft Azure DevOps Boards Spoke

 

You can use the Create Work Item action from the spoke and send in required details.