Integrating Privacy Rights Automation with ServiceNow

You can integrate your data subject requests with ServiceNow to automatically create an incident when a data subject request is logged through a web form.

The integration is also configured to update and manage subtasks on the request as work is completed and comments are added in ServiceNow.

To configure ServiceNow

This integration relies on REST APIs. In ServiceNow, you can complete the configuration using either table APIs or through Import Sets. This example shows configuration using the table APIs directly on the Incident table in ServiceNow.

This example shows basic authentication using a username and password. OneTrust recommends creating a service account user that has the itil and rest_service roles.

For more information about ServiceNow configuration, see ServiceNow Product Documentation.

  1. Go to System Definition > Business Rules.

    The Business Rules screen appears.

  2. Click the New button. A new business rule is created.
  3. Configure the business rule as shown below. This rule will be used to update the ServiceNow subtask on the request.


  4. Go to the advanced tab and paste the following script.

    Replace https://demo1.otprivacy.com with the correct url for your OneTrust account.

    Replace the API Key with the API key generated from your OneTrust account.

    JAVASCRIPT
    (function executeRule(current, previous /*null when async*/) {
    
    	try {
            var request = new sn_ws.RESTMessageV2();
            request.setHttpMethod('put');
           var endpoint = 'https://demo1.otprivacy.com/api/datasubject/v2/subtasks/'+ current.short_description + '/complete';
    		 var worknote = current.work_notes.getJournalEntry(1);
    		 var worknoteContent = worknote.split("(Work notes)\n");
    		 var lastWorknote = worknoteContent[1];
    		lastWorknote=lastWorknote.replace(/(\r\n|\n|\r)/gm, "");
    		var body = '{"comment":"SERVICENOW: '+''+lastWorknote+'","markAsComplete":false}';
    	   request.setEndpoint(endpoint);
    		request.setRequestHeader("Content-Type","application/json");
    		request.setRequestHeader("apiKey","{API KEY}");
    		request.setRequestHeader("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36");
    		request.setRequestBody(body);
    
            // api.myjson.com/bins/4j985 is just a static JSON data store
    
    
            var response = request.execute();
            var httpResponseStatus = response.getStatusCode();
            var httpResponseContentType = response.getHeader('Content-Type');
            var parser = new global.JSONParser();
            var parsed = {};
            var httpResponseBody;
    
    
            gs.debug("http response status_code: " + httpResponseStatus);
            gs.debug("http response content-type: " + httpResponseContentType);
    
    
            //  if request is successful then parse the response body
            if (httpResponseStatus == 200 && httpResponseContentType == 'application/json') {
                httpResponseBody = response.getBody();
    
                //  parse JSON string returned from request into a json object
                parsed = parser.parse(httpResponseBody);
    
                // iterate over JSON object only printing the id property of JSON objects in results array
                for (var i = 0; i < parsed.results.length; i++) {
                    gs.print('id: ' + parsed.results[i].id);
                }
            }
        }
        catch (ex) {
            var message = ex.getMessage();
            gs.debug(message);
        }
    
    })(current, previous);
  5. Add another business rule using the configuration shown below:


  6. Go to the advanced tab and paste the following script.

    Replace https://demo1.otprivacy.com with the correct url for your OneTrust account.

    Replace the API Key f90eef46d17e60b4fb26e21aea7a7481 with the API key generated from your OneTrust account.

    JAVASCRIPT
    (function executeRule(current, previous /*null when async*/) {
    
    	try {
            var request = new sn_ws.RESTMessageV2();
            request.setHttpMethod('put');
           var endpoint = 'https://demo1.otprivacy.com/api/datasubject/v2/subtasks/'+ current.short_description + '/complete';
    		 var closeNote = current.close_notes;
    		closeNote=closeNote.replace(/(\r\n|\n|\r)/gm, "");
    		var body = '{"comment":"Ticket CLOSED From SERVICENOW with following details, Code: '+current.close_code+' Close notes: '+''+closeNote+'","markAsComplete":true}';
    	   request.setEndpoint(endpoint);
    		request.setRequestHeader("Content-Type","application/json");
    		request.setRequestHeader("apiKey","f90eef46d17e60b4fb26e21aea7a7481");
    		request.setRequestHeader("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36");
    		request.setRequestBody(body);
    
            // api.myjson.com/bins/4j985 is just a static JSON data store
    
    
            var response = request.execute();
            var httpResponseStatus = response.getStatusCode();
            var httpResponseContentType = response.getHeader('Content-Type');
            var parser = new global.JSONParser();
            var parsed = {};
            var httpResponseBody;
    
    
            gs.debug("http response status_code: " + httpResponseStatus);
            gs.debug("http response content-type: " + httpResponseContentType);
    
    
            //  if request is successful then parse the response body
            if (httpResponseStatus == 200 && httpResponseContentType == 'application/json') {
                httpResponseBody = response.getBody();
    
                //  parse JSON string returned from request into a json object
                parsed = parser.parse(httpResponseBody);
    
                // iterate over JSON object only printing the id property of JSON objects in results array
                for (var i = 0; i < parsed.results.length; i++) {
                    gs.print('id: ' + parsed.results[i].id);
                }
            }
        }
        catch (ex) {
            var message = ex.getMessage();
            gs.debug(message);
        }
    
    })(current, previous);

To configure the integration workflow

After you configure the business rules in ServiceNow, you need to configure the integration workflow that will connect to ServiceNow from OneTrust.

  1. Configure the Basic Auth credentials. For more information about how to configure credentials, see Configuring Integration Credentials.
  2. Go to the Gallery menu in the Integrations module and search for ServiceNow.


  3. In the Gallery Details screen for ServiceNow, click the Add button on the Data Discovery tile.


    The Add Workflow Name modal appears.

  4. Complete the fields, then click the Create button.


    The Workflow Builder screen appears.

  5. Update the second step in the workflow (ServiceNow: POST CreateTicket) to use the credentials configured for your ServiceNow instance.


  6. Update the Comment field in the third action of the workflow, as needed.


  7. Save and then activate the workflow.

To add an integration to your DSAR workflow

  1. On the Data Subject Request menu, select Workflows.

    The Workflows screen appears.

  2. Click on the name of a Draft workflow.

    The Workflow Details screen appears.

  3. Go to the stage at which you want to add the integration.
  4. Click the System Subtask button.

    The Add System Subtask modal appears.

  5. Complete the fields.
    Field
    Description
    Task Name

    Enter a name for the subtask.

    System

    Select the system that will be used to complete the subtask.

    System Integration Workflow

    Select the integration workflow that will be used to complete the subtask.

    Task Description

    Enter a brief description of the task and its purpose.

    Run Manually

    Select this check box to require a manual action to launch the subtask.

    Required

    Select this check box to make the subtask required to complete the request.

  6. Click the Save button.
  7. Click the Activate button. A confirmation dialog appears.
  8. Click the Activate button. The subtask will now appear for all future requests associated with the workflow.

Add System Subtask Screen Reference