User's Preferences - System Notification

shun6
Giga Sage

Hi all,

 

I want to prevent each users from disabling 'System Notifications' so that user always receive notifications.

Is there any System Propeties to hide this option? or each user's attribute is stored at table and I can create Business rule? 

 

Indivisual  User's Preferences > Notifications > System Notification

shun6_1-1717121081463.png

 

 

3 REPLIES 3

Community Alums
Not applicable

Hi @shun6 ,

 

Check this Post & this

 

If my answer helped you in any way, please mark it as helpful or correct.

Vaishnavi Lathk
Mega Sage
Mega Sage

Hello @shun6 ,

 

Client Script 

In some cases, you may need a Client Script to enforce the UI policy dynamically.

  1. Navigate to Client Scripts:

    • In the application navigator, type "Client Scripts" and click on it.
  2. Create a New Client Script:

    • Click on the "New" button to create a new Client Script.
  3. Configure the Client Script:

    • Table: sys_user_preference
    • Type: OnLoad
    • Script:

 

 
function onLoad() {
    var notificationField = g_form.getField('glide.ui.notification_system');
    if (notificationField) {
        g_form.setDisplay(notificationField, false);
    }
}
  1. Save the Client Script.
  2.  

Hide the Notification Preferences Option

To further ensure that users cannot see or interact with the notification preferences, you can hide this option using a UI Policy or Client Script.

  1. Navigate to UI Policies:

    • In the application navigator, type "UI Policies" and click on it.
  2. Create a New UI Policy:

    • Click on the "New" button to create a new UI Policy.
  3. Configure the UI Policy:

    • Table: sys_user_preference
    • Condition: name == 'glide.ui.notification_system'
    • On load: Ensure this is checked.
    • Reverse if false: Uncheck this.
  4. UI Policy Actions:

    • Create a new UI Policy Action to hide the field.
    • Field name: value (or the field representing the notification setting)
    • Visible: False
  5. Save the UI Policy.

 

Create a Business Rule to Enforce Notification Settings

To ensure users cannot disable system notifications, you can create a Business Rule that prevents the update or creation of preferences that disable notifications.

  1. Navigate to Business Rules:

    • In the application navigator, type "Business Rules" and click on it.
  2. Create a New Business Rule:

    • Click on the "New" button to create a new Business Rule.
  3. Configure the Business Rule:

    • Name: Prevent Disabling System Notifications
    • Table: sys_user_preference
    • Advanced: Check the "Advanced" checkbox to write a script.
  4. Script:

    • Write a script to prevent users from changing the notification settings.

Here's an example of a script to prevent users from disabling system notifications:

(function executeRule(current, previous /*null when async*/) {
    // Check if the preference being modified is related to notifications
    if (current.name == 'glide.ui.notification_system' && current.value == 'false') {
        // Prevent the change by setting the preference back to true
        current.value = 'true';
        gs.addErrorMessage('Disabling system notifications is not allowed.');
    }
})(current, previous);
 
Regards,
Vaishnavi Lathkar

PrashantLearnIT
Giga Sage

Hi @shun6 , 

 

Please have a look on below articles to fulfil your requirements:

1. Solved: Re: How to prevent disabling system notification? - ServiceNow Community

2. Solved: Re: Prevent users from disabling their notificatio... - ServiceNow Community

 

 

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************