Count Records
count_recordsCount records on a ServiceNow table with an optional encoded query filter. Use the Stats API for efficient server-side counting to quickly gauge data volumes.
Instructions
Count records on any ServiceNow table, optionally filtered by an encoded query. Uses the Stats API for efficient server-side counting — much faster than querying all records and counting client-side.
Use this to quickly gauge data volumes (e.g., how many open P1 incidents, how many users in a group, how many CIs of a given class).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instance | No | The ServiceNow instance auth alias (e.g., "myinstance", "prod"). If not provided, falls back to the SN_AUTH_ALIAS environment variable. | |
| table | Yes | The ServiceNow table name to count records on (e.g., "incident", "sys_user", "cmdb_ci_server"). | |
| query | No | An encoded query string to filter which records are counted. Examples: "active=true^priority=1", "state!=7". If omitted, counts all records in the table. |