Service Now
Overview
Integrate ServiceNow with Enov8 to automatically send Change Request and Incident data to the Enov8 platform upon creation or updates. This integration ensures real-time synchronization between ServiceNow and Enov8, enhancing visibility and streamlining ITSM processes.
Prerequisites
Before setting up the integration, ensure the following:
- ServiceNow Access: Administrative access to create and manage Business Rules.
- Enov8 Webhook Endpoint: Obtain the Enov8 webhook URL and required headers (
App-Id
,App-Key
). - RESTMessageV2 API: Ensure that the RESTMessageV2 API is enabled in your ServiceNow instance.
Integration Steps
1. Create a Business Rule in ServiceNow
-
Navigate to System Definition → Business Rules.
-
Click New to create a new Business Rule.
-
Fill in the following details:
Field Value Name Send to Enov8 on Create/Update Table change_request or incident Advanced Checked When after Insert Checked Update Checked (if updates should trigger the webhook) Filter Condition Optional: current.active == true
2. Add Script to the Business Rule
Click on the "Advanced" tab and add the following code in the Script section, customizing the endpoint and headers as needed. The payload can also be changed as required.
Sample Code
(function executeRule(current) {
gs.info('🔔 Business Rule triggered for Change Request: ' + current.number);
try {
var r = new sn_ws.RESTMessageV2();
r.setEndpoint('[REPLACE WITH WEBHOOK URL]');
r.setHttpMethod('POST');
// Add Headers
r.setRequestHeader("Content-Type", "application/json");
r.setRequestHeader("App-Id", "[REPLACE WITH APP ID]");
r.setRequestHeader("App-Key", "[REPLACE WITH APP KEY]");
// Format sys_created_on to ISO 8601 with fake microseconds
var gdt = new GlideDateTime(current.sys_created_on);
var formattedDate = gdt.getDisplayValueInternal().replace(" ", "T") + ".000000";
// Get tags if tag field or tag table is used (may need customization)
var tags = "";
if (current.tags) {
tags = current.tags.toString();
}
// Construct payload
var payload = {
"type": "ChangeRequest",
"sys_id": current.sys_id.toString(),
"change_id": current.number.toString(),
"short_description": current.short_description.toString(),
"description": current.description.toString(),
"created_by": current.opened_by.getDisplayValue(),
"created_on": formattedDate,
"status": current.state.getDisplayValue(),
"priority": current.priority.getDisplayValue(),
"impact": current.impact.getDisplayValue(),
"assignment_group": current.assignment_group ? current.assignment_group.getDisplayValue() : "",
"assigned_to": current.assigned_to ? current.assigned_to.getDisplayValue() : "",
"tags": tags
};
var jsonPayload = JSON.stringify(payload);
gs.info('📦 Sending payload to Enov8: ' + jsonPayload);
r.setRequestBody(jsonPayload);
// Execute and log response
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.info('✅ Webhook sent to Enov8. Status: ' + httpStatus + ', Response: ' + responseBody);
} catch (ex) {
gs.error('❌ Webhook to Enov8 failed: ' + ex.message);
}
})(current);
3. Save and Test the Business Rule
- Click Submit to save the Business Rule.
- Create or update a Change Request or Incident in ServiceNow.
- Verify that the payload is sent to Enov8 by checking the logs under System Logs → All or Outbound HTTP Requests.
Payload Example
{
"type": "ChangeRequest",
"sys_id": "e0d4b20a47c32200c574b8c5a0f6a94b",
"number": "CHG0030051",
"short_description": "Migrate Database",
"description": "Migrate Oracle to cloud",
"created_by": "Jane Doe",
"created_on": "2025-06-08T17:35:12.000000",
"status": "Scheduled",
"priority": "High",
"impact": "Moderate",
"assignment_group": "DB Team",
"assigned_to": "John Smith",
"tags": "migration,oracle"
}
Notes
- Table Selection: Ensure the Business Rule is associated with the correct table (
change_request
orincident
). - Field Availability: Verify that all referenced fields (e.g.,
tags
) exist in your ServiceNow instance. - Security: Store sensitive information like
App-Id
andApp-Key
securely, possibly using ServiceNow's Credential Store. - Error Handling: Implement additional error handling as needed to manage failed webhook attempts.