From 18106213e5c747340640b962d49d966515aed325 Mon Sep 17 00:00:00 2001 From: Divya <165976969+divyajetti9@users.noreply.github.com> Date: Mon, 13 Oct 2025 09:28:32 -0500 Subject: [PATCH 1/2] find inactive users README.md --- .../GlideRecord/find inactive users in user table/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Core ServiceNow APIs/GlideRecord/find inactive users in user table/README.md diff --git a/Core ServiceNow APIs/GlideRecord/find inactive users in user table/README.md b/Core ServiceNow APIs/GlideRecord/find inactive users in user table/README.md new file mode 100644 index 0000000000..941ab42a39 --- /dev/null +++ b/Core ServiceNow APIs/GlideRecord/find inactive users in user table/README.md @@ -0,0 +1 @@ +This script finds users who are inactive in the sys_user table who have not logged in for over 90 days From 878e2508cf2c03d6b59b4736bfc029dc19235120 Mon Sep 17 00:00:00 2001 From: Divya <165976969+divyajetti9@users.noreply.github.com> Date: Mon, 13 Oct 2025 09:31:05 -0500 Subject: [PATCH 2/2] Create ListofUserRecords.js --- .../ListofUserRecords.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Core ServiceNow APIs/GlideRecord/find inactive users in user table/ListofUserRecords.js diff --git a/Core ServiceNow APIs/GlideRecord/find inactive users in user table/ListofUserRecords.js b/Core ServiceNow APIs/GlideRecord/find inactive users in user table/ListofUserRecords.js new file mode 100644 index 0000000000..dc55fb99bb --- /dev/null +++ b/Core ServiceNow APIs/GlideRecord/find inactive users in user table/ListofUserRecords.js @@ -0,0 +1,17 @@ +// This script finds users who are inactive or haven't logged in for 90+ days + +var today = new GlideDateTime(); +var ninetyDaysAgo = new GlideDateTime(); +ninetyDaysAgo.addDaysUTC(-90); + +var gr = new GlideRecord('sys_user'); +gr.addQuery('active', false); // user is inactive +gr.addOrCondition('last_login_time', '<', ninetyDaysAgo); // or last login before 90 days ago +gr.query(); + +var oldUsers = []; +while (gr.next()) { + oldUsers.push(gr.getValue('name')); +} + +gs.info('Inactive or old users: ' + oldUsers.join(', '));