Business Rules configuration is required for automating processes and enforcing business logic within the platform. It enables proper synchronization of data between ServiceNowand Jira.
Follow the below steps to create Business Rules in your ServiceNow platform:
Step 1: Login to ServiceNow account.
Step 2: Click on All and search Business Rules. Select Business Rules under Administration option.
...
Step 4: Create business rules to push data from ServiceNow to JIRA.
Add Name.
Example: clouddata_center_create_itemissue
Click on Table dropdown and select Incident [Incident].
Click on the Advanced checkbox.
Select Click on Submit.
...
After submitting it will redirected to the Business Rules main window.
Step 5: Open the newly added Business Rule.
...
Step 6: Go to the When to run tab and fill in the below details in the fields.
Click on the When dropdown and select the after option.
Add value 100 to the Order field.
Select the Insert checkbox.
Add below Filter ConditionsClick on the choose field dropdown and select Jira Issue Key.
Click on starts with dropdown and select is empty.
...
Click on Update.
...
Select Advanced tab and add the below given script.
...
Copy the script below and paste it in the Advanced tab.
Code Block |
---|
try {
gs.log("####START OF INCIDENT UPDATE####");
var request = new sn_ws.RESTMessageV2('JIRA Update Issue', 'PUT');
request.setEndpoint(request.getEndpoint() + current.u_jira_issue_key);
gs.log("##The End Point :"+request.getEndpoint(),'UpdateJiraForDemo');
var currentIssueKey = current.u_jira_issue_key;
var currentDescription = current.description.replace(/\n|\r/g, " ");
var currentDescriptionSplit = currentDescription.split("-------------------------------------------------------------");
gs.log("The End Point"+request.getEndpoint(),'UpdateJiraForDemo');
var currentShortDesc = current.short_description.getDisplayValue();
var requestBody = {
fields: {
summary: currentShortDesc,
description: currentDescriptionSplit[1]
};
gs.log("The request body :"+JSON.stringify(requestBody),'UpdateJiraForDemo');
request.setRequestBody(JSON.stringify(requestBody)) ;
var response = request.execute();
var httpStatus = response.getStatusCode();
gs.log("The Status Code "+ httpStatus,'UpdateJiraForDemo');
gs.log("####END OF INCIDENT UPDATE####",'UpdateJiraForDemo');
}
catch(ex) {
var message = ex.message;
}
})(current, previous); |
Click on Save button to update the script.
...
Click on Submit.
...