Before provisioning the integration in ServiceNow, customers must get API user ID/password from TrustArc. Customer’s TrustArc Sales can help in procuring these credentials.
- Setting up API user in ServiceNow for TrustArc to access tables
- Setting up Inbound OAuth Authentication
- Setting up Outbound OAuth Authentication in ServiceNow (from ServiceNow to TrustArc)
- Setting up Outbound REST message in ServiceNow
- Setting up business rules in ServiceNow
Setting up API user in ServiceNow for TrustArc to access tables
NOTE: You must have admin role privileges to access ServiceNow.
- Log in to your ServiceNow account.
-
From the left side of the homepage, navigate to User Administration (1) > Users (2), and then click New (3).
-
Set up the following for the user, and then click Submit.
Field Value User ID Provide an appropriate user ID Password Provide password First name First name of the user Last name Last name of the user Title Provide an appropriate title Active Select this checkbox Web Service Access Only Select this checkbox Email Email ID of the user Roles Select “Admin,” “Personalize Dictionary,” “itil”
Setting up Inbound OAuth Authentication
NOTE: This requires admin role privileges in ServiceNow.
-
From the homepage, navigate to System OAuth (1) > Application Registry (2), and then click New (3).
-
On the Interceptor page, click Create an OAuth API endpoint for external clients, and then fill in the form as follows:
Field Value Name A distinguishable name for this OAuth client.
Example : TrustArc API Account
Client ID System default ID or you can create your own one. Client Secret A client secret for TrustArc to authenticate against your ServiceNow. Application Global Accessible from Select All Application Scopes. Refresh Lifespan Token 8,640,000 Token Lifespan 1,800 - Click Submit.
Setting up Outbound OAuth Authentication in ServiceNow (from ServiceNow to TrustArc)
-
From the homepage, navigate to System OAuth (1) > Application Registry (2), and then click New (3).
-
Click Connect to a third-party OAuth provider (4), and then fill in the form as follows:
Field Value Name A unique name Client ID ClientID provided by TrustArc Client Secret Client Secret provided by TrustArc Default Grant Type Select “Client credentials” Refresh Token Lifespan 8,640,000 Accessible from Select “All Application Scopes” Active Select the checkbox Token URL https://api.trustarc.com/api/auth/oauth/token - Click Submit.
Setting up Outbound REST message in ServiceNow
-
From the homepage, navigate to System Web Services (1) > Outbound (2) > REST Message (3), and then click New (4).
-
Fill the fields with the following values, and then click Submit.
Field Value Name Provide a distinguishable name Application Global Accessible from This application scope only Endpoint https://api.trustarc.com/api/integration/event Authentication type OAuth 2.0 OAuth Profile Name of the OAuth Profile created - Open the RESET message that you have created, and to the right of HTTP Methods, click New (5).
-
Provide the values to the following fields:
Field Value Name Provide a distinguishable name HTTP method POST Endpoint https://api.trustarc.com/api/integration/event Authentication tab > Authentication Type Inherit from parent HTTP Request tab > HTTP Headers > Accept application/json HTTP Request tab > HTTP Headers > Content-Type application/json
Setting up business rules in ServiceNow
-
From the homepage, navigate to Metrics (1) > Business Rules (2), and then click New (3).
-
Provide the fields with the following values:
Field Value Name Provide a distinguishable name Table Select a table from which you would like to sync the data to the Data Mapping & Risk Manager Application Global Active Select the checkbox Advanced Select the checkbox -
In the Advanced tab (4), copy the JavaScript below and paste it to the Script field in the tab:
JavaScript for Business Rules
(function executeRule(current, previous /*null when async*/) {
try {
var d = new GlideDateTime();
var ms = d.getNumericValue();
// Debug purpose
gs.print('sys entity Id=' + current.getValue('sys_id'));
gs.print('eventTraceId=' + gs.generateGUID());
gs.print('entityName=' + current.number);
gs.print('tableName=' + current.getTableName());
gs.print('created=' + new Date(ms).toISOString());
var r = new sn_ws.RESTMessageV2('<Outbound Message Name*>', '<HTTP Method Name*>');
var requestBody = {
entityId: current.getValue('sys_id'),
eventTraceId : gs.generateGUID(),
entityName : current.number.toString(),
tableName : current.getTableName(),
created : new Date(ms).toISOString()
};
r.setRequestBody(JSON.stringify(requestBody));
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
// Debug purpose
gs.info("Response Body = "+responseBody);
gs.info("HTTP Status = "+httpStatus);
} catch (ex) {
var message = ex.getMessage();
}
})(current, previous);NOTES:
- In JavaScript, the Outbound Message Name needs to be replaced with the outbound REST message name entered while setting up Outbound REST Message.
- In JavaScript, the HTTP Method Name needs to be replaced with the HTTP method name created while setting up Outbound REST Message.