Remove a recipient from a Email Notification

Community Alums
Not applicable

Can we remove a particular recipient from Email Notification being sent. This Notification is sent to glide field recipients.

Any suggestions will be helpful.   Thanks!!

1 ACCEPTED SOLUTION

Kumar35
Tera Expert

this is what I did recently in a before insert business rule on sys_email -



var usermails = current.recipients.split(",");


var usermails1 = current.recipients.split(",");



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


  var gr = new GlideRecord('sys_user');


  gr.addQuery('email',usermails[i]);


  gr.query();


  if(gr.next())


  {


  var cuser = gs.getUser();


    cuser = cuser.getUserByID(gr.user_name);


    if (your conditon to remove the recipient)


  {  


  usermails1.splice(i, 1);


  }


  }


}


current.recipients = usermails1.toString();


View solution in original post

10 REPLIES 10

My suggestion will completely stop a user from receiving only that notification, all other notification types will still be received. That said, it is possible to add a filter per user, so that they will receive the specific notification based on a particular criteria.



Impersonate the user, and go to Notification Preferences as before. Click on the name of the notification on the list, then check the advanced filter box. From there you can add a custom query to filter what the user will receive.



Advanced Filter.png


Community Alums
Not applicable

I like your suggestion. My issue is with user complaining of him receiving two Notifications one for "Assigned To You" and "Updated by" whenever a ticket gets updated. Can i make this Notification customizing of notifications generic for all the user to not receive two notifications. Thanks!!


I see. In this case you may want to change the Weight value on the notification record itself. If two notifications for the same table are sent to a user at the same time, the notification with the higher weight will be sent and the other ignored. So you may want to set the Assigned To You weight to 100 and Updated By to 1. This way the user will only receive the Assigned to You notification. This is of course applicable globally for all users.



Email weighting is described on this wiki page (scroll down slightly to get to the table with Weight in it):



http://wiki.servicenow.com/index.php?title=Email_Notifications#Creating_Email_Notifications


Community Alums
Not applicable

Appreciate your OOTB solutions suggested Adam. Thank you.


Unfortunately increasing weight of my notification didn't help. I am trying to figure out something through script.


Adam pinned down your problem.   Just find the one that is more important and make it heavier