Disable Notification Devices on Deactivation of User#1758
Disable Notification Devices on Deactivation of User#1758SrijanPatwa wants to merge 2 commits intoServiceNowDevProgram:mainfrom
Conversation
This onAfter business rule script checks for the inactivated user and then disables the notification devices and Notification subscriptions of that particular user. This help us to keep the data aligned, prevent any unnecessary notifications or triggers and enhances security.
This onAfter business rule script checks for the inactivated user and then disables the notification devices and Notification subscriptions of that particular user. This help us to keep the data aligned, prevent any unnecessary notifications or triggers and enhances data management. It will also eliminate the manual efforts.
|
|
||
| var notifDevice = new GlideRecord('cmn_notif_device'); | ||
| notifDevice.addQuery('user', currentUserId); | ||
| notifDevice.addQuery('active', true); |
There was a problem hiding this comment.
|
|
||
| var notifSubs = new GlideRecord('sys_notif_subscription'); | ||
| notifSubs.addQuery('user', currentUserId); | ||
| notifSubs.addQuery('active', true); |
There was a problem hiding this comment.
| notifDevice.addQuery('user', currentUserId); | ||
| notifDevice.addQuery('active', true); | ||
| notifDevice.query(); | ||
| while (notifDevice.next()) { |
There was a problem hiding this comment.
Are you expecting multiple results? If you only expect one record, it is more efficient to fetch that 1 record.
| notifSubs.addQuery('user', currentUserId); | ||
| notifSubs.addQuery('active', true); | ||
| notifSubs.query(); | ||
| while (notifSubs.next()) { |
There was a problem hiding this comment.
Are you expecting multiple results? If you only expect one record, it is more efficient to fetch that 1 record.
| This onAfter business rule script checks for the inactivated user and then disables the notification devices and Notification | ||
| subscriptions of that particular user. | ||
|
|
||
| This help us to keep the data aligned, prevent any unnecessary notifications or triggers and enhances data management. It will |
There was a problem hiding this comment.
Notifications will not trigger for inactive users.
Can you think of other benefits that this script might help accomplish?
|
Thank you for your submission. I have added comments to the code. In general, it will be helpful to describe better why you think this script is beneficial. Did you encounter an issue at in an instance that this business rule now solves? |
PR Description:
Pull Request Checklist
Overview
Code Quality
Repository Structure Compliance
Core ServiceNow APIs/Server-Side Components/Client-Side Components/Modern Development/Integration/Specialized Areas/Documentation
Restrictions