Skip to content

Commit 05020f7

Browse files
authored
disableNotifDevices.js
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.
1 parent be1fd1a commit 05020f7

File tree

1 file changed

+26
-0
lines changed
  • Server-Side Components/Business Rules/Disable Notification Devices and Subscription on user deactivation

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
3+
var currentUserId = current.getUniqueValue();
4+
5+
var notifDevice = new GlideRecord('cmn_notif_device');
6+
notifDevice.addQuery('user', currentUserId);
7+
notifDevice.addQuery('active', true);
8+
notifDevice.query();
9+
while (notifDevice.next()) {
10+
notifDevice.active = false;
11+
notifDevice.update();
12+
}
13+
14+
15+
var notifSubs = new GlideRecord('sys_notif_subscription');
16+
notifSubs.addQuery('user', currentUserId);
17+
notifSubs.addQuery('active', true);
18+
notifSubs.query();
19+
while (notifSubs.next()) {
20+
notifSubs.active = false;
21+
notifSubs.update();
22+
}
23+
24+
25+
26+
})(current, previous);

0 commit comments

Comments
 (0)