The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Manage Subscriptions to Notifications in Service Portal

christophes_
Tera Guru

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

1 ACCEPTED SOLUTION

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


View solution in original post

5 REPLIES 5

Laxmikanth
Tera Expert

Hi Chris,



You may find this thread helpful



Reset Notification Preferences


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


Christophe, would you be willing to share this widget?

Thousif S N2
Tera Contributor

Hello,

I am looking for similar requirement, Could you please share the widget XML.?

 

Regards,

Thousif