From 05020f748effc7594e35b24e8ce7116d07f42854 Mon Sep 17 00:00:00 2001
From: SrijanPatwa <148682493+SrijanPatwa@users.noreply.github.com>
Date: Fri, 3 Oct 2025 23:53:54 +0530
Subject: [PATCH 1/2] 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.
---
.../disableNotifDevices.js | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 Server-Side Components/Business Rules/Disable Notification Devices and Subscription on user deactivation/disableNotifDevices.js
diff --git a/Server-Side Components/Business Rules/Disable Notification Devices and Subscription on user deactivation/disableNotifDevices.js b/Server-Side Components/Business Rules/Disable Notification Devices and Subscription on user deactivation/disableNotifDevices.js
new file mode 100644
index 0000000000..ab8a62a74b
--- /dev/null
+++ b/Server-Side Components/Business Rules/Disable Notification Devices and Subscription on user deactivation/disableNotifDevices.js
@@ -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);
+ notifDevice.query();
+ while (notifDevice.next()) {
+ notifDevice.active = false;
+ notifDevice.update();
+ }
+
+
+ var notifSubs = new GlideRecord('sys_notif_subscription');
+ notifSubs.addQuery('user', currentUserId);
+ notifSubs.addQuery('active', true);
+ notifSubs.query();
+ while (notifSubs.next()) {
+ notifSubs.active = false;
+ notifSubs.update();
+ }
+
+
+
+})(current, previous);
From fd51714d79ec4e52342444c4503f26d9727fc43c Mon Sep 17 00:00:00 2001
From: SrijanPatwa <148682493+SrijanPatwa@users.noreply.github.com>
Date: Sat, 4 Oct 2025 00:01:46 +0530
Subject: [PATCH 2/2] readme.md
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.
---
.../readme.md | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 Server-Side Components/Business Rules/Disable Notification Devices and Subscription on user deactivation/readme.md
diff --git a/Server-Side Components/Business Rules/Disable Notification Devices and Subscription on user deactivation/readme.md b/Server-Side Components/Business Rules/Disable Notification Devices and Subscription on user deactivation/readme.md
new file mode 100644
index 0000000000..6eb416fed9
--- /dev/null
+++ b/Server-Side Components/Business Rules/Disable Notification Devices and Subscription on user deactivation/readme.md
@@ -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
+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'
+
+
+
+
+
+5. In 'Advanced' section: Paste the script of [disableNotifDevices.js]
+
+