Multiple Incident in one Email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 01:52 PM
Hello,
I have a requirement that when an Incident or Task has not been updated for 60 or more days the Assigned to will receive an email notification. Finding the old items in easy enough, but is there a way to send all incidents assigned to the same person in one email?
Just using the demo data as an example but let's say the five Beth has are all over 60 days, how to I notify her about all five in one email? And then do the same for everyone else in the list.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 03:58 PM
Work out the query to gather up the old incidents and group them by assigned to. The filter control will give you most of what you need. Implement that as a GlideRecord query and work out how to iterate over the groups.
For each group assemble a JSON object describing the assign-to, and the incidents sys_ids, and whatever else you might want to pass to a notification.
Fire off an event and pass this object (stringified) as a param.
Create a Notification and have it respond to this event.
Put in Notification Email Scripts to read and parse the param and transform it into whatever you need, for example a table.
To run a Notification Email Script in your Message HTML:
<p><span style="font-size: 10pt;">${mail_script:rf.sr.ack.reminder.content} </span></p>
Example of setting the Subject from a Notification Email Script:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// parm1 is recipients
// parm2 is the rfid aka terminalid of the related Device. This makes a more useful label
// than anything from the service request itself.
email.setSubject(event.parm2 +" is being submitted for repair");
template.print("<p>If acknowledgement of...<p>");
...
})(current, template, email, email_action, event);
That will override whatever you put in the Subject field. I don't remember if the Subject allows use of mail scripts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 04:00 PM
Hi, I would consider a scheduled job to query your data set on a daily (or weekly basis), using GlideAggregate to identify assignees who have 1 or more Incidents/tasks assigned to them and for each assignee trigger a sysevent (to trigger a notification).
Then in the notification use a notification email script to query tasks for the assignee involved, formatting the results into your notification body.