-
Notifications
You must be signed in to change notification settings - Fork 907
Disable Notification Devices on Deactivation of User #1758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable Notification Devices on Deactivation of User #1758
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| var notifSubs = new GlideRecord('sys_notif_subscription'); | ||
| notifSubs.addQuery('user', currentUserId); | ||
| notifSubs.addQuery('active', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| notifDevice.addQuery('user', currentUserId); | ||
| notifDevice.addQuery('active', true); | ||
| notifDevice.query(); | ||
| while (notifDevice.next()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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