- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
Have a requirement to see the SLA breach emails in the Incident Activity stream like how other emails we see eg when incident is resolved. I am trying to copy the emails from task sla to incident using a before insert Business rule and in filter condition using type is sent ready and target table is task sla
making sure only emails are copied for only the below mentioned notifications.
here is the code
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Business Rule :
(function executeRule(current, previous /*null when async*/ ) {
if (current.target_table == 'task_sla') {
var logGR = new GlideRecord('sys_email_log');
logGR.addQuery('email', current.sys_id);
logGR.query();
while (logGR.next()) {
if (logGR.notification.name == 'SLA warning Parm') {
var slaGR = new GlideRecord('task_sla');
if (slaGR.get(current.instance)) {
if (slaGR.task && slaGR.task.sys_class_name == 'incident') {
current.target_table = 'incident';
current.instance = slaGR.task.sys_id;
current.update();
}
}
}
}
}
})(current, previous);
To display SLA breach/warning emails in the Incident Activity Stream without modifying OOB behavior, we implemented an Async Business Rule on sys_email.
The Business Rule checks if the email is generated for task_sla, and then retrieves the related notification using the sys_email_log table. Since sys_email_log records are created only after the email record is inserted, the Business Rule is configured as Async to ensure the notification details are available.
Only specific SLA notifications (like “SLA warning Parm”) are filtered, and for those emails, the script updates the email record to point to the related Incident instead of task_sla. This ensures that the email appears in the Incident Activity Stream, just like other standard notifications (e.g., Incident resolved).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Update your logic. Have the emails trigger from the incident table. Depending on what configuration you use, have the 'sla breach' logic trigger events to trigger the notification of use 'send notification' actions in the flow, triggering the notification on the record the SLA is on.
That's the only way to actually see the emails in the same way.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Business Rule :
(function executeRule(current, previous /*null when async*/ ) {
if (current.target_table == 'task_sla') {
var logGR = new GlideRecord('sys_email_log');
logGR.addQuery('email', current.sys_id);
logGR.query();
while (logGR.next()) {
if (logGR.notification.name == 'SLA warning Parm') {
var slaGR = new GlideRecord('task_sla');
if (slaGR.get(current.instance)) {
if (slaGR.task && slaGR.task.sys_class_name == 'incident') {
current.target_table = 'incident';
current.instance = slaGR.task.sys_id;
current.update();
}
}
}
}
}
})(current, previous);
To display SLA breach/warning emails in the Incident Activity Stream without modifying OOB behavior, we implemented an Async Business Rule on sys_email.
The Business Rule checks if the email is generated for task_sla, and then retrieves the related notification using the sys_email_log table. Since sys_email_log records are created only after the email record is inserted, the Business Rule is configured as Async to ensure the notification details are available.
Only specific SLA notifications (like “SLA warning Parm”) are filtered, and for those emails, the script updates the email record to point to the related Incident instead of task_sla. This ensures that the email appears in the Incident Activity Stream, just like other standard notifications (e.g., Incident resolved).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Thank you Sneha
