Notification Email Scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hi All,
I have written a e-mail script to display the incident summary in the notification.
Email script:
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hello @Aswin Chandras1
I assume you are likely intending to send notifications from the sysapproval_approver records.
Since the sysapproval column in sysapproval_approver is a reference field for the task table, it cannot access fields defined in incident.
I think it would be best to retrieve the sys_id from the sysapproval column and use glideRecord to fetch the data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Here is the sample code.
I haven't thoroughly tested it, so please check it carefully.
var incident_sysid = current.sysapproval.getValue();
var incident_record = new GlideRecord('incident');
incident_record.get(incident_sysid);
if(incident_record){
template.print("<table>");
template.print("<tr><td><strong>Caller:</strong></td><td>" + incident_record.caller_id.getDisplayValue() + "</td></tr>");
template.print("<tr><td><strong>Assignment group:</strong></td><td>" + incident_record.assignment_group.getDisplayValue() + "</td></tr>");
template.print("<tr><td><strong>Assigned to:</strong></td><td>" + incident_record.assigned_to.getDisplayValue() + "</td></tr>");
template.print("</table>");
template.print("<div><strong>Description:</strong></div><div>" + incident_record.description + "</div>");
template.print("<div> </div>");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
I believe you are writing notification on sysapproval_approver table
share some screenshots and extra details
If yes then modify the script as this
var incident_record = new GlideRecord('incident');
incident_record.addQuery('sys_id', current.sysapproval);
incident_record.query();
if (incident_record.next()) {
template.print("<table>");
template.print("<tr><td><strong>Caller:</strong></td><td>" + incident_record.caller_id.getDisplayValue() + "</td></tr>");
template.print("<tr><td><strong>Assignment group:</strong></td><td>" + incident_record.assignment_group.getDisplayValue() + "</td></tr>");
template.print("<tr><td><strong>Assigned to:</strong></td><td>" + incident_record.assigned_to.getDisplayValue() + "</td></tr>");
template.print("</table>");
template.print("<div><strong>Description:</strong></div><div>" + incident_record.description + "</div>");
template.print("<div> </div>");
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader