Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Step 2: Find the "ServiceNow Connector for Jira on Cloud" and click "Install."

3. Overview:

...

Figure 1: Create issue from Jira and Update the issue from ServiceNow/Jira

Use Case to check this application

  • If a user creates an issue in Jira then the plugin will create the corresponding incident in service now

  • It syncs all values from Jira Issue to ServiceNow incident including component, reporter, assignee, custom fields, attachment, and comments based on the mapping of the fields.

  • If user updates incident in Jira then the plugin updates the same values in the service now.

  • It links the Jira issue key to the ServiceNow field and ServiceNow incident number to Jira Issue.

  • Users can easily track changes and sync between two different systems using this seamless integration.

Note : Similarly user can create incident from ServiceNow to Jira, and updates can flow from Jira to ServiceNow OR User can create and update issues from both the applications.(ServiceNow and Jira)

4. Configure the plugin in JIRA:

...

Code Block
//This code is used to create Jira Issue from servicenow
(function executeRule(current, previous /*null when async*/ ) {

    try {
        // Add your code here
        var request = new sn_ws.RESTMessageV2('10_CloudJiraIssueSync', 'create_cloud_issue');
// rest message and name which we have created needs to be added here.
		request.setRequestHeader		request.setRequestHeader("Authorization", "Basic "+Base 64 token); // Base 64 token can be generated like this ${Email}:${API Key}
		
        var sourceData = "JiraCloudServiceNowIntegrationCreateIssue";

        var jira_issue_id = "10020"; // Jira issue type id iswe can hardcordedget forit onefrom issuetypeJira
        var jira_project_key = "CUS"; // Jira project key iswe can hardcordedget forit onefrom projectJira
        var incident_number = current.number;
        var incident_sysId = current.sys_id;
        var incident_short_description = current.short_description;
        gs.log("The incident_short_description" + incident_short_description, sourceData);

        request.setEndpoint(request.getEndpoint());
        gs.log("##The End Point :" + request.getEndpoint(), sourceData);

        var currentIssueKey = current.u_jira_issue_key;
        var currentDescription = current.description.replace(/\n|\r/g, " ");

        var currentShortDesc = current.short_description.getDisplayValue();
        var requestBody = {
            "fields": {
                "summary": currentShortDesc,
                "issuetype": {
                    "id": jira_issue_id
                },
                "customfield_10033": incident_number.toString(),  //this is the customfield from Jira we have created to store the number "SN NUmber"
                "customfield_10034": incident_sysId.toString(),   //this is the customfield from Jira we have created to store the sysid "SN SysId"
                "project": {
                    "key": jira_project_key
                },
                "description": {
                    "type": "doc",
                    "version": 1,
                    "content": [{
                        "type": "paragraph",
                        "content": [{
                            "text": currentDescription,
                            "type": "text"
                        }]
                    }]
                }
            }
        };

        gs.log("The request body :" + JSON.stringify(requestBody), sourceData);
        request.setRequestBody(JSON.stringify(requestBody));
        var response = request.execute();
        var httpStatus = response.getStatusCode();
        var httpResponseBody = response.getBody();
        var responseObject = JSON.parse(httpResponseBody);
        gs.log("The Jira Key is #:" + responseObject.key, sourceData);
        gs.log("The Status Code #:" + httpStatus, sourceData);
        gs.log("The Response Body #:" + httpResponseBody, sourceData);
        current.u_jira_issue_key = responseObject.key;
        current.update();
        gs.log("####END OF INCIDENT UPDATE####", sourceData);
    } catch (ex) {
        var message = ex.message;
        gs.log("The error message " + message, sourceData);

    }


})(current, previous);

...