The Now Platform® Washington DC release is live. Watch now!
09-28-2017 02:09 AM
Hi community,
we are currently trying to develop a service portal widget where the user can change the notifications preferences.
We have found solutions to integrate or link to the ServiceNow Notification Preferences page (/notification_preferences.do), but our need is to create a new design that is fully integrated into our Service Portal.
Here you see our solution:
The user just has a checkbox to register or not to a notification preference.
If the check box is checked, it calls the server-side function "enableNotifications (userSysId, notificationSysId, true)"
Otherwise, it calls the server-side function "enableNotifications (userSysId, notificationSysId, false)"
Service script
function enableNotifications(userSysId, notificationSysId, value){
var notif_message = new GlideRecord("cmn_notif_message");
notif_message.addQuery("user", userSysId);
notif_message.addQuery("notification", notificationSysId);
notif_message.query();
if (notif_message.getRowCount() == 1) {
notif_message.next();
notif_message.send_email = value;
notif_message.update();
}
}
The cmn_notif_message.send_email field is correctly updated but the toggle button in Notification Preferences page (/notification_preferences.do) don't change. The notifications are always sent regardless of the stored value 😕
Do you have any idea to resolve our problem ?
Is the modification of table cmn_notif_message a good solution or is there a best way ?
Thanks in advance
Christophe
Solved! Go to Solution.
09-29-2017 06:57 AM
Hi Laxmikanth,
thanks for your answer.
In fact, I have take a look in the UI Page "notification_preferences" and found the used field : notification_filter .
Now, we change the value of the notification_filter field in our custom widget and it works fine.
if notification_filter = '', the user receives the email notification.
if notification_filter = 'c1bfa4040a0a0b8b001eeb0f3f5ee961', the user doesn't receive the email notification.
function enableNotifications(userSysId, notificationSysId, value){
var notif_message = new GlideRecord("cmn_notif_message");
notif_message.addQuery("user", userSysId);
notif_message.addQuery("notification", notificationSysId);
notif_message.query();
if (notif_message.getRowCount() == 1) {
notif_message.next();
if(value)
notif_message.notification_filter = '';
else
notif_message.notification_filter = 'c1bfa4040a0a0b8b001eeb0f3f5ee961';
notif_message.update();
}
}
Best Regards
Christophe
09-29-2017 05:35 AM
09-29-2017 06:57 AM
Hi Laxmikanth,
thanks for your answer.
In fact, I have take a look in the UI Page "notification_preferences" and found the used field : notification_filter .
Now, we change the value of the notification_filter field in our custom widget and it works fine.
if notification_filter = '', the user receives the email notification.
if notification_filter = 'c1bfa4040a0a0b8b001eeb0f3f5ee961', the user doesn't receive the email notification.
function enableNotifications(userSysId, notificationSysId, value){
var notif_message = new GlideRecord("cmn_notif_message");
notif_message.addQuery("user", userSysId);
notif_message.addQuery("notification", notificationSysId);
notif_message.query();
if (notif_message.getRowCount() == 1) {
notif_message.next();
if(value)
notif_message.notification_filter = '';
else
notif_message.notification_filter = 'c1bfa4040a0a0b8b001eeb0f3f5ee961';
notif_message.update();
}
}
Best Regards
Christophe
09-05-2018 10:59 AM
Christophe, would you be willing to share this widget?
09-17-2021 06:17 AM
Hello,
I am looking for similar requirement, Could you please share the widget XML.?
Regards,
Thousif