Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ServiceNow New Incident Slack Notification #servicenow #slack #businessrule
// ServiceNow New Incident Slack Notification
// Business Rule
// SlackIncidentNewNotify.js
// Rich Bocchinfuso - 2017/05/10
// debug only
// var inc ='####'; // add incident sys_id you wnat to use for debugging
// var current = new GlideRecord('incident');
// if (current.get(inc)) {
// Initialize a new SlackMessage
var slack = new SlackMessage();
// create payload
slack.payload.text = 'New Incident ' + current.number.toString() + ' (' + current.short_description + ')' + ':';
slack.payload.icon_url = 'https://www.idmworks.com/wp-content/uploads/2015/04/servicenow-icon.png';
slack.payload.attachments.push({
'title': current.number.toString() + ' (' + current.short_description + ')',
'title_link': 'https://' + gs.getProperty('instance_name') + '.service-now.com/nav_to.do?uri=incident.do?sys_id=' + current.sys_id,
'text': '\n Customer: ' + current.company.getDisplayValue() + '\n Location: ' + current.location.getDisplayValue() + '\n Opened by: ' + current.opened_by.getDisplayValue() + '\n Caller: ' + current.caller_id.getDisplayValue() + '\n Assigned to: <' + current.assigned_to.u_slack_username.getDisplayValue() + '>\n Category: ' + current.category.getDisplayValue() + '\n CMDB Item: ' + current.cmdb_ci.getDisplayValue() + '\n Priority: ' + current.priority.getDisplayValue() + '\n Description: ' + current.description
});
// fire message
slack.send();
// } // uncomment for debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment