File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed
Server-Side Components/Background Scripts/GetRecordsFromMultipleTables Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change 1- Creating a background script to print the total count of all tables with a specific filter condition
1+ A background script that retrieves record counts from multiple ServiceNow tables with date filtering, providing a comprehensive data audit report.
2+
3+ ## What It Does
4+
5+ The script:
6+ 1 . Defines an array of table names to query (60+ tables by default)
7+ 2 . Iterates through each table using ` forEach() ` to process them systematically
8+ 3 . Uses ` GlideAggregate ` with COUNT aggregate for efficient record counting
9+ 4 . Applies a date filter to count records updated before a specific date
10+ 5 . Handles errors gracefully with try-catch blocks for invalid table names
11+ 6 . Outputs results in a formatted table structure with pipe separators
12+
13+
14+ ## Sample Output
15+
16+ ```
17+ | Table | Records
18+ | customer_account | 1,245 records
19+ | cmn_location | 87 records
20+ | customer_contact | 3,456 records
21+ | cmdb_ci | 12,789 records
22+ We've got an error for table: invalid_table_name
23+ ```
24+
25+ ## Configuration Options
26+
27+ - ** Date filtering** : Modify ` sys_updated_on<=javascript:gs.dateGenerate('YYYY-MM-DD','HH:mm:ss') ` to change the cutoff date
28+ - ** Custom table list** : Replace the ` tablesList ` array with your specific tables of interest
29+ - ** Additional filters** : Add more encoded query conditions like ` active=true ` or specific field criteria
You can’t perform that action at this time.
0 commit comments