ServiceNow Integration allows you to:

  • Creating an incident in Rootly will create an incident in ServiceNow if you choose to.
  • Changing incident title, description, status in Rootly will update the incident in ServiceNow.

Installation

You can setup this integration as a logged in admin user in the integrations page:

Configuration

First login to your service now instance and let’s create an OAuth application:

  1. Click on System OAuth > Application Registry as shown below:

  2. Click on New as shown below:

  3. Click on Create an OAuth API endpoint for external clients as shown below:

  4. Fill out and as shown below: Name: Rootly

    Redirect Url: https://rootly.com/auth/service\_now/callback

  5. Copy your instance url and client Id and client secret generated:

You are all set!

Webhooks

  1. In your ServiceNow instance, go to System Definition > Business Rules.
  2. Select New.
  3. Give your new Business Rule a descriptive name, choose what table you want it to trigger on, and check the Advanced box.
  4. Next, choose After for when you want it to run. You may also choose to add filter conditions, but we want it to trigger for all incident tickets in this example. Also, for this example, we want to select Insert because we want it to trigger when a new incident ticket is created.
  5. Navigate to the Advanced tab. In the Script editor, add the following code. Make sure to replace <insert webhook public URL> with whatever the webhook target is. The target URL may be a web server that will parse and use the data or another service that accepts incoming webhooks.
  6. Lastly, replace the <secret> field with the sercret key of your webhook API.
    (function executeRule(current, previous /*null when async*/ ) {
        try {
            var r = new sn_ws.RESTMessageV2();
            r.setEndpoint("<insert webhook public URL>");
            r.setHttpMethod("post");
            r.setRequestHeader("secret", "<secret>");
    
            // getValue(string) does not support dot walking, 
            // so I had to do a bit more to get the user’s email address
            var usr = new GlideRecord('sys_user');
            usr.get('sys_id', current.getValue("caller_id"));
            var reported_by_email = usr.getValue('email');
    
            // Make sure to convert object references to values.
            // More info at: 
            // https://swissbytes.blogspot.com/2017/11/service-now-script-includes-make-sure.html
    
            var number = current.getValue("number");		
            var opened_at = current.getValue("opened_at");
            var impact = current.getValue("impact");
            var urgency = current.getValue("urgency");
            var short_description = current.getValue("short_description");
            var description = current.getValue("description");
            var category = current.getValue("category");
            var priority = current.getValue("priority");
            var sys_id = current.getValue("sys_id");
            var subcategory = current.getValue("subcategory");
            var state = current.getValue("state");
    
            var obj = {
                "number": number,
                "reported_by_email": reported_by_email,
                "opened_at": opened_at,
                "impact": impact,
                "urgency": urgency,
                "short_description": short_description,
                "description": description,
                "category": category,
                "priority": priority,
                "sys_id": sys_id,
                "subcategory": subcategory,
                "state": state
            };
            
            var body = JSON.stringify(obj);
            gs.info("Webhook body: " + body);
            r.setRequestBody(body);
    
            var response = r.execute();
            var httpStatus = response.getStatusCode();
        } catch (ex) {
            var message = ex.message;
            gs.error("Error message: " + message);
        }
    
        gs.info("Webhook target HTTP status response: " + httpStatus);
    
    })(current, previous);
    

Uninstall

You can uninstall this integration in the integrations panel by clicking Configure > Delete

Support

If you need help or more information about this integration, please contact support@rootly.com or use the lower right chat widget to get connected with an engineer.

Was this page helpful?