Update Github State When ServiceNow Incident State is Updated

ServiceNow logo

Update Github State When ServiceNow Incident State is Updated

Objective: Whenever a ServiceNow incident is closed, I want to update its corresponding Github issue with a comment and close it

  1. In ServiceNow go into Business Rule and Click Create new. Given that you want to trigger an even whenever an incident state is updated to Resolved or Closed follow the following steps

2. As Shown in the screenshot, in the Table drop-down select incident

3.  When do you want it triggered? After a change takes place, as a result, in the When drop down selected After

4. Check the Update checkbox, because we want to trigger an event when an incident is updated

5. As it’s highlited, we can have multipe conditions there. What the screesnhot above suggest is

If State of an incident is updated to Resolved OR Closed, trigger an event.

6. We need a simple script which will be triggered as a result of the conditions met in Step 5, for which click the Advanced tab and paste the following snippet of the code:

(function testFunction() {

try {
var request = new sn_ws.RESTMessageV2();
request.setBasicAuth(“rickyBobby1”, “Password1”);
request.setRequestBody(‘{“body”:”Closing the issue from ServiceNow”,”state”:”close”}’);
var response = request.execute();
var httpResponseStatus = response.getStatusCode();

gs.print(“http response status_code: ” + httpResponseStatus);


catch (ex) {
var message = ex.getMessage();

Like so:


Leave a Reply