From 61213ddd805520875b664f92996d6507380dfd35 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 19 Oct 2025 14:15:56 -0700 Subject: [PATCH] improved read me --- .../GetRecordsFromMultipleTables/README.md | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Server-Side Components/Background Scripts/GetRecordsFromMultipleTables/README.md b/Server-Side Components/Background Scripts/GetRecordsFromMultipleTables/README.md index 9dca85ed62..1628ef61d0 100644 --- a/Server-Side Components/Background Scripts/GetRecordsFromMultipleTables/README.md +++ b/Server-Side Components/Background Scripts/GetRecordsFromMultipleTables/README.md @@ -1 +1,29 @@ -Creating a background script to print the total count of all tables with a specific filter condition +A background script that retrieves record counts from multiple ServiceNow tables with date filtering, providing a comprehensive data audit report. + +## What It Does + +The script: +1. Defines an array of table names to query (60+ tables by default) +2. Iterates through each table using `forEach()` to process them systematically +3. Uses `GlideAggregate` with COUNT aggregate for efficient record counting +4. Applies a date filter to count records updated before a specific date +5. Handles errors gracefully with try-catch blocks for invalid table names +6. Outputs results in a formatted table structure with pipe separators + + +## Sample Output + +``` +| Table | Records +| customer_account | 1,245 records +| cmn_location | 87 records +| customer_contact | 3,456 records +| cmdb_ci | 12,789 records +We've got an error for table: invalid_table_name +``` + +## Configuration Options + +- **Date filtering**: Modify `sys_updated_on<=javascript:gs.dateGenerate('YYYY-MM-DD','HH:mm:ss')` to change the cutoff date +- **Custom table list**: Replace the `tablesList` array with your specific tables of interest +- **Additional filters**: Add more encoded query conditions like `active=true` or specific field criteria \ No newline at end of file