Last active
October 5, 2017 19:09
-
-
Save rbocchinfuso/7d930b95c0a8b2773ce9c4d3ab72ada5 to your computer and use it in GitHub Desktop.
ServiceNow Escalate Incident Slack Notification #servicenow #slack #businessrule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ServiceNow Escalate Incident Slack Notification | |
// Business Rule | |
// SlackIncidentEscalateNotify.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(); | |
var incident_url = 'https://' + gs.getProperty('instance_name') + '.service-now.com/nav_to.do?uri=incident.do?sys_id=' + current.sys_id; | |
// create payload | |
gs.info('create payload'); | |
slack.payload.channel = '#escalation'; | |
slack.payload.text = 'Incident ' + current.number.toString() + ' (' + current.short_description + ') ' + 'escalated to ' + current.priority.getDisplayValue() + ' from ' + previous.priority.getDisplayValue() + ' by <' + current.sys_updated_by + '>' + ':'; | |
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': incident_url, | |
'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 | |
gs.info('fire message'); | |
slack.send(); | |
gs.info('boom!'); | |
//} // uncomment for debug |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment