Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Core ServiceNow APIs/GlideRecord/IncidentCount/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Incident Count

## Description
This snippet demonstrates how to count the total number of incident records in ServiceNow using the GlideRecord API.

## Usage
This code can be run in:
- Background Scripts
- Script Includes
- Business Rules
- Scheduled Jobs

## Code Example
```javascript
var gr = new GlideRecord('incident');
gr.query();
var count = gr.getRowCount();
gs.info('Total number of incidents: ' + count);
```

## API Used
- GlideRecord - Core ServiceNow API for database operations
- getRowCount() - Returns the number of rows in the query result

## Notes
- This snippet uses getRowCount() which is efficient for counting records
- The query() method must be called before getRowCount()
- You can add encoded queries before calling query() to count specific records

## Related
- [GlideRecord Documentation](https://developer.servicenow.com/dev.do#!/reference/api/latest/server/no-namespace/c_GlideRecordScopedAPI)

## Tags
#GlideRecord #Incidents #Count #ServerSide
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Count the number of incident records
var gr = new GlideRecord('incident');
gr.query();
var count = gr.getRowCount();
gs.info('Total number of incidents: ' + count);
Loading