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

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();


Community Alums
Not applicable

Thank you Kumar. I hope your solution works for me.



Cheers!!


domaners
Kilo Guru

You can remove this notification from the users profile by impersonating that user and switching off the notification from their profile. To do this, impersonate the user, then click My Profile > Notification Preferences. Find the notification name from this list and click Off to disable it for that user. NOTE that this will only be visible if the user has already received a notification of this type. If they haven't there's another way to do it.



Type "cmn_notif_message.do" on to the left-hand navigation pane. You will need to then personalize the form and add the "Send Email" and "User" fields. When that is done, enter the name of the notification into the Notification Message field, enter the users name into the User field. Uncheck the Send Email field then save. That user will no longer receive mails of that type.



If you want to do this for a mass of users, you can do it via a background script. Let me know if you need help with that.


Community Alums
Not applicable

Thanks Adam for your response. But my requirement was not to restrict a user completely from receiving notifications. I only required to restrict user in a particular Email Notification when a condition is satisfied.