From de1f7c2d4886e5f4a752f3148d6713c7821a974a Mon Sep 17 00:00:00 2001 From: Code with bhav <92107107+bhavyaa30@users.noreply.github.com> Date: Tue, 14 Oct 2025 22:54:26 +0530 Subject: [PATCH 1/2] script.js --- .../script.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Check Number of Active Records per Table/script.js diff --git a/Server-Side Components/Background Scripts/Check Number of Active Records per Table/script.js b/Server-Side Components/Background Scripts/Check Number of Active Records per Table/script.js new file mode 100644 index 0000000000..f17e14d7e6 --- /dev/null +++ b/Server-Side Components/Background Scripts/Check Number of Active Records per Table/script.js @@ -0,0 +1,22 @@ +// Script: Check Number of Active Records per Table +// Author: Bhavya +// Use: To count active records in multiple tables + +(function() { + // List of tables you want to check + var tables = ['incident', 'change_request', 'problem', 'task']; + + gs.print('Active Record Count per Table'); + + for (var i = 0; i < tables.length; i++) { + var tableName = tables[i]; + var gr = new GlideRecord(tableName); + + // Filter for active records + gr.addQuery('active', true); + gr.query(); + + var count = gr.getRowCount(); + gs.print(tableName + " - Active Records: " + count); + } +})(); From f6ccb9ff123745d06e534a352b8aba5ccff6e316 Mon Sep 17 00:00:00 2001 From: Code with bhav <92107107+bhavyaa30@users.noreply.github.com> Date: Tue, 14 Oct 2025 22:57:20 +0530 Subject: [PATCH 2/2] readme.md --- .../Check Number of Active Records per Table/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Server-Side Components/Background Scripts/Check Number of Active Records per Table/readme.md diff --git a/Server-Side Components/Background Scripts/Check Number of Active Records per Table/readme.md b/Server-Side Components/Background Scripts/Check Number of Active Records per Table/readme.md new file mode 100644 index 0000000000..0f73c7f136 --- /dev/null +++ b/Server-Side Components/Background Scripts/Check Number of Active Records per Table/readme.md @@ -0,0 +1 @@ +This background script allows ServiceNow administrators and developers to quickly check the number of active records across multiple tables such as Incident, Change Request, Problem, or Task.