Skip to content

Instantly share code, notes, and snippets.

@rbocchinfuso
Last active October 5, 2017 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbocchinfuso/828f4a8c45e6e9ffb4c8b30acef29475 to your computer and use it in GitHub Desktop.
Save rbocchinfuso/828f4a8c45e6e9ffb4c8b30acef29475 to your computer and use it in GitHub Desktop.
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