Deactivate Notification for all users in notification preferences
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 12:10 AM
Hi is it possible that an email notification is optional and it is always disabled by default in the Notification Preferences and can be enabled by the users if needed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 12:35 AM
HI @florian29
Try this way create an entry in cmn_notif_message for all users for that particular notification as unsubscribed. This way the users can subscribe if they need it, otherwise it will be defaulted to unsubscribed.
For new users, you can create an After - Insert BR on user table and add script to add the unsubscribed entry in cmn_notif_message table.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2024 08:28 PM
Hi Florian,
Yes, It is possible.
Pls refer the script below.
Fix Script:
var prefGr = new GlideRecord('sysevent_email_action');
prefGr.addEncodedQuery('your query here');//paste the required filter query here
prefGr.query();
while (prefGr.next()) {
var use=new GlideRecord('sys_user');
use.addQuery('active',true);
use.query();
while(use.next()){
var ins = new GlideRecord('sys_recipient_notif_preference');
ins.initialize();
ins.recipient_table ='sys_user';
ins.recipient = use.sys_id;
ins.notification_table = 'sysevent_email_action';
ins.notification = prefGr.sys_id;
ins.send = false;
ins.insert();
}
}
This script is used to set the required notifications to false in preference tables for all the users.