Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(function executeRule(current, previous /*null when async*/ ) {

var currentUserId = current.getUniqueValue();

var notifDevice = new GlideRecord('cmn_notif_device');
notifDevice.addQuery('user', currentUserId);
notifDevice.addQuery('active', true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notifDevice.query();
while (notifDevice.next()) {
Copy link
Contributor

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.

notifDevice.active = false;
notifDevice.update();
}


var notifSubs = new GlideRecord('sys_notif_subscription');
notifSubs.addQuery('user', currentUserId);
notifSubs.addQuery('active', true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notifSubs.query();
while (notifSubs.next()) {
Copy link
Contributor

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.active = false;
notifSubs.update();
}



})(current, previous);
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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
Copy link
Contributor

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?

also eliminate the manual efforts.


Business Rule Setup:
1. Name: Manage Inactive user Notif Devices [Amend it as suitable]
2. Table: [sys_user]
3. When to run: 'After' 'Update'
4. Condition: 'Active' 'Changes to' 'False'


<img width="1619" height="517" alt="image" src="https://github.com/user-attachments/assets/428b706e-0aee-4b08-9028-58d309bb8c90" />


5. In 'Advanced' section: Paste the script of [disableNotifDevices.js]

<img width="859" height="682" alt="image" src="https://github.com/user-attachments/assets/98ad7122-56ad-48d8-8f1a-43a4727d0ead" />
Loading