Created
August 24, 2018 20:56
-
-
Save rbocchinfuso/939dc9032c855e924bd4a44af4d4ca40 to your computer and use it in GitHub Desktop.
ServiceNow New Incident Slack Notification
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 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