Skip to content

Commit de1f7c2

Browse files
authored
script.js
1 parent de3ed58 commit de1f7c2

File tree

1 file changed

+22
-0
lines changed
  • Server-Side Components/Background Scripts/Check Number of Active Records per Table

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Script: Check Number of Active Records per Table
2+
// Author: Bhavya
3+
// Use: To count active records in multiple tables
4+
5+
(function() {
6+
// List of tables you want to check
7+
var tables = ['incident', 'change_request', 'problem', 'task'];
8+
9+
gs.print('Active Record Count per Table');
10+
11+
for (var i = 0; i < tables.length; i++) {
12+
var tableName = tables[i];
13+
var gr = new GlideRecord(tableName);
14+
15+
// Filter for active records
16+
gr.addQuery('active', true);
17+
gr.query();
18+
19+
var count = gr.getRowCount();
20+
gs.print(tableName + " - Active Records: " + count);
21+
}
22+
})();

0 commit comments

Comments
 (0)