Skip to main content
All CollectionsIntegrations
Data Push Destinations: ServiceNow
Data Push Destinations: ServiceNow

Send UXI data to your ServiceNow instance.

Updated over a month ago

Selecting the Generic HTTP Endpoint destination will send your test result data or issue data to your HTTP Endpoint database. For example, consider the ServiceNow instance. Additionally, you can perform more actions in this SNOW scripted REST API, such as:

  • Assigning issues to specific teams based on the sensor’s group and reported issue type.

  • Setting different priorities for issues, depending on their importance to your application compared to others.

For instance, you might prioritize issues related to your own application over those affecting other applications.

To get started with the UXI Data Push Destinations for Generic HTTP Endpoint (SNOW):

Navigate to Scripted REST API

Create your API

  • Click on the New button to start creating your API.

  • Give your API a Name and an ID.

  • Click on the Submit button to save this API.

Select your API and create a new unauthenticated resource

  • After creating your API, you will be redirected to a list of APIs.

  • Search for your API and select it.

  • Create a new resource by clicking on the New button at the bottom of the page.

Use the script below as a template:

This example shows how to create a POST request. We will be using it to post an alert. The alert details are contained in:

request.body.data.text

Final script for REST API

(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
gs.info(request.body.data);
var issues = request.body.data;
for (item=0; item<issues.length; item++){
var issue_uid = issues[item].uid;
var issue_code = issues[item].code;
var issue_snow_id = issue_code+'_'+issue_uid;
var issue_severity = issues[item].severity;
var issue_status = issues[item].event_type;
var issue_timestamp = issues[item].timestamp;
var issue_work_notes = issues[item];
var inc = new GlideRecord('incident');
if (issue_status == 'CREATED') {
inc.initialize();
inc.work_notes = JSON.stringify(issue_work_notes);
inc.short_description = issue_snow_id; // set this to identify the incident later for resolved messages
inc.insert();
gs.info('Incident created');

} else if (issue_status == 'RESOLVED') {
inc.get("short_description", issue_snow_id);
inc.state = 7;
inc.update();
gs.info('Incident closed');
}
}
return {
"status": "PROCESSED"
};
}
)(request, response);

If you are using the ServiceNow Event Management plugin, your script may look like this:

(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
gs.info(request.body.data);
var issues = request.body.data;
for (item=0; item<issues.length; item++){
var issue_uid = issues[item].uid;
var issue_code = issues[item].code;
var issue_sensor_name = issues[item].context.sensor_name;
var issue_network_name = issues[item].context.network_name;
var issue_hierarchy_node_name = issues[item].context.hierarchy_node_name;
var issue_service_name = issues[item].context.service_name;
var issue_severity = issues[item].severity;
var issue_status = issues[item].event_type;
var issue_work_notes = issues[item];

var emEventGr = new GlideRecord('em_event');

emEventGr.initialize();
emEventGr.setValue('message_key',issue_uid);
emEventGr.setValue('source', issue_network_name);
emEventGr.setValue('node', issue_sensor_name);
emEventGr.setValue('type', issue_code);
emEventGr.setValue('resource', issue_service_name);
emEventGr.setValue('description', issue_code);
emEventGr.setValue('additional_info', issue_hierarchy_node_name);
if (issue_status == 'CREATED') {
emEventGr.setValue('state', 'Ready');
emEventGr.state = 3;
gs.info('Issue created');

} else if (issue_status == 'RESOLVED') {
emEventGr.setValue('resolution_state', 'Closing');
emEventGr.state = 7;
gs.info('Issue resolved');
}
else {
continue;
}

emEventGr.insert();
gs.info('issue processed');
}
return {
"status": "PROCESSED"
};
}
)(request, response);


​Once this is done, in the UXI dashboard, go to Settings > Integrations. In the Data Push Destinations section, click on the Add Destination button.

Specify the following information in the Add Destination modal that appears:

  • Data Type: Test Results or Issues.

  • Destination Type: Generic HTTP Endpoint.

  • Name: Give this integration a friendly name.

  • URL: Enter the ServiceNow public URL = ServiceNow instance URL + Base API path.

  • Username: Provide a username for the ServiceNow user the data push destination will use to add documents.

  • Password: Enter the password for the ServiceNow user the data push destination will use to add documents.

    Click on the Add button.

    Here is a short demo setting up the data push destination for ServiceNow.

Did this answer your question?