How to send SLA breached notification only to assignment group members with a specific role

CDJ
Tera Contributor

Hi All,

I have a requirement related to SLA breached notifications in the task_sla table.


The OOTB breached notifications are triggered at 25%, 50%, 75%, and 100% SLA percentage, and they send to configured recipients.

I have created a new notification (instead of modifying the OOTB one), and I want it to:

  • Send only to assignment group members of the task linked to the SLA record.

  • Further filter those members so it only sends if the user has the xyz_sla role.

The challenge:

  • In the Who will receive section of the notification form, I don’t see the “Users/Groups in a script” option in my instance (UI policy hides it?).

  • I want to keep the OOTB percentage events (25%, 50%, 75%, 100%) but only send to the filtered group members.

Questions:

  1. How can I implement recipient filtering in this case?

  2. Any best practice for keeping the OOTB SLA percentage logic intact while filtering recipients?

  3. We are getting the user details in logs but unable to print it

script :

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,

          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,

          /* Optional GlideRecord */ event) {

    var task = current.task.getRefRecord();

var util = new GetAssignmentGroupUsersWithRole(); // Script include to return all assignemnt group members

var userIds = util.getUsersWithRole(task, 'xyz_sla');

 

 gs.log("EmailScript: Found users with xyz_sla =1 " + userIds.join(", "));

for (var i = 0; i < userIds.length; i++) {

    template.print('<g:include type="recipient" table="sys_user" sys_id="' + userIds[i] + '"/>'); // Not Working values received in for loop is a=not getting added as reciepient

}

}

 

Thanks in advance!

1 REPLY 1

Mark Manders
Mega Patron

The OOB percentages come from the (work)flow. The notifications are triggered from there, so to use the same, you should add your notification to the same trigger.

However, I would like to suggest to create a separate flow for this (or add the logic into the existing flow) and don't use the notifications, but the 'send email' action within the flow. The email will be created within the flow and you can easily do lookups within the flow to the task's assignment group, to the sys_user_grmember table and for those members, the sys_user_has_role table. Add the email addresses in the 'send email' action 'to' field and you're there.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark