Skip to content

Commit 5551f52

Browse files
authored
improved read me (#2318)
1 parent 5a01b94 commit 5551f52

File tree

1 file changed

+29
-1
lines changed
  • Server-Side Components/Background Scripts/GetRecordsFromMultipleTables

1 file changed

+29
-1
lines changed
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
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

0 commit comments

Comments
 (0)