Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to Link SLA breach emails from TASK SLA table to Incident worknotes activity stream

SAS21
Tera Guru

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

var notifications = ['CSC - INC SLA notification for 50%,70%',
        'INC SLA notification for 80%',
        'CSC - INC SLA breached'
    ];
    var notif_name = current.notification.getDisplayValue();
    gs.info('found notif' + notif_name);
    if (notifications.indexOf(notif_name) > -1) {
        var slaGR = new GlideRecord('task_sla');
        if (slaGR.get(current.instance)) {
            if (slaGR.task.sys_class_name == 'incident') {
                current.target_table = 'incident';
                current.instance = slaGR.task;
            }
        }
    }
 
its not working... Appreciate the help.
 
Thank you
 
1 ACCEPTED SOLUTION

snehareddym
Tera Guru

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).ā€ƒ

 

Screenshot 2026-04-09 at 2.02.02 PM.png

View solution in original post

3 REPLIES 3

Mark Manders
Giga Patron

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

snehareddym
Tera Guru

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).ā€ƒ

 

Screenshot 2026-04-09 at 2.02.02 PM.png