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

suvro
Mega Sage
Mega Sage

Can you write all this in async Business rule

 

 

sahana hattikal
Tera Contributor

Hi Suvro,

It is defined in get method, Please check the attachment

 

Eric Smith
Tera Expert

Sahana, hi. Did you use any tool to configure the integration? Maybe there is something with the trigger? We use a tool, zigiops connector, to help us automatically set the integration. So far, we haven't encountered issues with the connection between the systems. The workitem ids get automatically created so we not have to worry about that.

Vishal36
Mega Guru

Hi @sahana hattikal,

 

The implementation of a custom integration solution needs very high technical expertise on Azure DevOps APIs.

If you are open to less technical alternatives for ServiceNow and Azure DevOps integration, you can try out OpsHub’s free Community Edition, which integrates standard entities. A ServiceNow partner and a certified integration tool,  OpsHub offer a federated integration platform that can help ease your integration journey. Please refer to ServiceNow Integration with Azure DevOps Server (TFS) for more details. 

 

OpsHub takes care of the following use cases, also:    

  • Integration Richness:  It is very important to integrate complete information of Work items on ServiceNow and Azure DevOps instances; For any information missed in the integration, data on the instances might be different and it gets unreliable and unusable, over time.  OpsHub can integrate the complete work item information such as attachments, web links, comments, traceability, and inline images on ServiceNow and TFS instances. 
  • Field-level Conflict Management: As this is a bi-directional integration, there is a possibility of data being updated simultaneously in both instances. OpsHub supports field-level conflict management in such cases. 
  • Data Granularity: OpsHub integration solution also integrates history between ServiceNow and the Azure DevOps. E.g., between the two syncs, if the user modifies the status from Open -> In Progress -> Resolved on Azure DevOps, the OpsHub integration tool allows users to see the exact transition (Open -> In Progress -> Resolved) happening in ServiceNow too.  
  • Supported entities: All System and Custom Tables(Incidents etc.) on ServiceNow and all work items such as Bugs, Requirements, Tasks, Test Cases, User Stories, Shared Steps, Iterations, etc. on Azure DevOps are supported by the OpsHub integration tool.  

OpsHub’s Commercial Edition additionally supports the integration of more advanced data. 

You can reach out to OpsHub’s integration experts for an initial free consultation on a discussion on your use case and planning of integration strategy.