Is it possible to disable email notifications for users based on regions?

Chitra23
Tera Contributor

Hi,

 

Our customer instance is domain separated and has multiple regions(like APAC, US etc.,). Some of the users are complaining that they are receiving too many email notifications for incident/RITM/Change commented etc., Is it possible for the admin to disable these notifications by default for users based on their regions? The users can later enable the required notifications by enabling them in their preferences. Many Thanks

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @Chitra23 ,

 

if you want to turn off few notifications for the users try this 

you can run a fix script something like this.
you can identify the users based on countries and run the fix script per country.

and create a BR with same logic to take care of new users.

 
table: sys_recipient_notif_preference stores the user's notification preferences. setting send to false is equivalent to user themselves going to the preferences and turning off the particular notification.

 

var usrGr = new GlideRecord("sys_user");

var notifPrefGr = new GlideRecord('sys_recipient_notif_preference');
usrGr.addEncodedQuery("location.country=JAPAN"); // query based on user's country
usrGr.setLimit(10);
usrGr.query();
while (usrGr.next()) {
    //array of notifcation sysids can be added here

    notifPrefGr.newRecord();
    notifPrefGr.notification_table = 'sysevent_email_action';
    notifPrefGr.recipient_table = 'sys_user';
    notifPrefGr.recipient = usrGr.getValue('sys_id');
    notifPrefGr.notification = '3c705e2847ee42108ab7916a216d4350'; //sysid of the notification
	notifPrefGr.send = false; 
    notifPrefGr.insert();

}

 if you want to disable all the notifications for the users try this.

disable the notification devices of the user.

var usrGr = new GlideRecord("sys_user");

var ntfDevGr = new GlideRecord('cmn_notif_device');
usrGr.addEncodedQuery("location.country=JAPAN"); // query based on user's country
usrGr.setLimit(10);
usrGr.query();
while (usrGr.next()) {
ntfDevGr.addEncodedQuery('name=Primary email^type=Email^active=true^user='+usrGr.getValue('sys_id'));
ntfDevGr.query();
if(ntfDevGr.next()){
	ntfDevGr.active =false;
	ntfDevGr.update();
}

}

A BR to take care of new Users.

 

Please mark the answer as helpful and correct if helped.

Regards,

Chaitanya

 

View solution in original post

6 REPLIES 6

Chaitanya ILCR
Kilo Patron

Hi @Chitra23 ,

 

if you want to turn off few notifications for the users try this 

you can run a fix script something like this.
you can identify the users based on countries and run the fix script per country.

and create a BR with same logic to take care of new users.

 
table: sys_recipient_notif_preference stores the user's notification preferences. setting send to false is equivalent to user themselves going to the preferences and turning off the particular notification.

 

var usrGr = new GlideRecord("sys_user");

var notifPrefGr = new GlideRecord('sys_recipient_notif_preference');
usrGr.addEncodedQuery("location.country=JAPAN"); // query based on user's country
usrGr.setLimit(10);
usrGr.query();
while (usrGr.next()) {
    //array of notifcation sysids can be added here

    notifPrefGr.newRecord();
    notifPrefGr.notification_table = 'sysevent_email_action';
    notifPrefGr.recipient_table = 'sys_user';
    notifPrefGr.recipient = usrGr.getValue('sys_id');
    notifPrefGr.notification = '3c705e2847ee42108ab7916a216d4350'; //sysid of the notification
	notifPrefGr.send = false; 
    notifPrefGr.insert();

}

 if you want to disable all the notifications for the users try this.

disable the notification devices of the user.

var usrGr = new GlideRecord("sys_user");

var ntfDevGr = new GlideRecord('cmn_notif_device');
usrGr.addEncodedQuery("location.country=JAPAN"); // query based on user's country
usrGr.setLimit(10);
usrGr.query();
while (usrGr.next()) {
ntfDevGr.addEncodedQuery('name=Primary email^type=Email^active=true^user='+usrGr.getValue('sys_id'));
ntfDevGr.query();
if(ntfDevGr.next()){
	ntfDevGr.active =false;
	ntfDevGr.update();
}

}

A BR to take care of new Users.

 

Please mark the answer as helpful and correct if helped.

Regards,

Chaitanya

 

Chitra23
Tera Contributor

Thank you so much @Chaitanya ILCR  sys_recipient_notif_preference is the table I was looking for.