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

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Chitra23 

 

Can you try looking at cmn_notif_messages.

The cmn_notif_message tables stores all the email subscription on the instance.

You might have to modify/add few records there.

 

Please mark the answer as helpful and correct if helped.

Kind regards,

Ravi Chandra 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Chitra23 

 

I think in this case you need to correct your email as per regions / domain. If you speak from user side then a user can disable it at preference table. You can explore this:

AGLearnNGrow_0-1732866848811.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Chitra23
Tera Contributor

Hi @Dr Atul G- LNG , Thanks for your response. Instead of asking each and every user to disable notifications,  Is it possible for admin to bulk disable these notifications for users?

What happens when the user disables (for e.g. incident commented notification ) from the notification preference page? Which table store these data?

Hi @Chitra23 

 

No. There is no backend view ( only with scripts) it is possible to turnoff specific notifications for users. So either build a code or asked user to turn off.

 

What happens when the user disables (for e.g. incident commented notification ) from the notification preference page? Which table store these data?

Atul: In this case, that email will not land in users inbox. sys_user_preference in this table.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************