File tree Expand file tree Collapse file tree
Core ServiceNow APIs/GlideRecord/IncidentCount Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Incident Count
2+
3+ ## Description
4+ This snippet demonstrates how to count the total number of incident records in ServiceNow using the GlideRecord API.
5+
6+ ## Usage
7+ This code can be run in:
8+ - Background Scripts
9+ - Script Includes
10+ - Business Rules
11+ - Scheduled Jobs
12+
13+ ## Code Example
14+ ``` javascript
15+ var gr = new GlideRecord (' incident' );
16+ gr .query ();
17+ var count = gr .getRowCount ();
18+ gs .info (' Total number of incidents: ' + count);
19+ ```
20+
21+ ## API Used
22+ - GlideRecord - Core ServiceNow API for database operations
23+ - getRowCount() - Returns the number of rows in the query result
24+
25+ ## Notes
26+ - This snippet uses getRowCount() which is efficient for counting records
27+ - The query() method must be called before getRowCount()
28+ - You can add encoded queries before calling query() to count specific records
29+
30+ ## Related
31+ - [ GlideRecord Documentation] ( https://developer.servicenow.com/dev.do#!/reference/api/latest/server/no-namespace/c_GlideRecordScopedAPI )
32+
33+ ## Tags
34+ #GlideRecord #Incidents #Count #ServerSide
You can’t perform that action at this time.
0 commit comments