---
title: AgentNowHandler - Scoped
description: The AgentNowHandler script include provides methods that enable running check definitions on demand, checking the status of on demand executions and test check executions and for stopping background checks that were executed on demand.Creates an AgentNowHandler instance.Gets status of the request with the given ID.Gets the test check status of the given test result.Runs a check against the given configuration item.Stops a background check.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/server-api-reference/AgentNowHandlerAPIScoped.html
release: australia
product: Server API Reference
classification: server-api-reference
topic_type: concept
last_updated: "2026-03-12"
reading_time_minutes: 3
breadcrumb: [Server API reference, API reference, API implementation and reference]
---
# AgentNowHandler- Scoped
The AgentNowHandler script include provides methods that enable running check definitions on demand, checking the status of on demand executions and test check executions and for stopping background checks that were executed on demand.
This script include requires the Agent Client Collector Framework \(sn\_agent\) store application and is provided within the `sn_agent` namespace. For more information, refer to [Agent Client Collector](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/it-operations-management/acc-landing-page.md).
For the REST API solution, refer to [Agent Client Collector API](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/agnt_clnt_cll-api.md).
**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)
## AgentNowHandler - AgentNowHandler\(\)
Creates an AgentNowHandler instance.
|Name|Type|Description|
|----|----|-----------|
|None| | |
The following example shows how to initialize AgentNowHandler.
```
var handler = new sn_agent.AgentNowHandler();
```
## AgentNowHandler - getRequestStatus\(String requestId\)
Gets status of the request with the given ID.
|Name|Type|Description|
|----|----|-----------|
|requestId|String|A check request ID generated by calling the runCheckForCis\(\) method.|
|
Properties
|
Description
|
|---|
|
Object
|
Status of the request and any applicable error message.
|
|
status
|
Request status.Possible values:
- done – Check is successful.
- failure – Check has failed. See error message for details.
- mid\_flow – Request output is being handled by the MID server.
- processing – Check is in progress.
- timeout – Check processing exceeded time limit set in the runCheckForCis\(\) method.
Data type: String
|
|
err\_msg
|
Error message if any.Possible values:
- No agents found for relevant CIs.
- No background check request with given ID.
- No request with given ID.
- No test result with given ID.
- Request timeout.
Data type: String
|
The following example shows how to get the status of a request.
```
var handler = new sn_agent.AgentNowHandler();
var check = {checkDefId: "158279505372b30034b8ddeeff7b1270"};
var computerGr = new GlideRecord("cmdb_ci_computer");
computerGr.query();
var requestId = handler.runCheckForCis(computerGr, check, 0, 60);
var reqStatusJson = handler.getRequestStatus(requestId);
gs.info(JSON.stringify(reqStatusJson));
```
## AgentNowHandler - getTestResultStatus\(String testResultId\)
Gets the test check status of the given test result.
|Name|Type|Description|
|----|----|-----------|
|testResultId|String|A test result ID generated by creating a test check request.|
|
Properties
|
Description
|
|---|
|
status
|
Status of the test results.Possible values:
- 0: Pending
- 1: In progress
- 2: Complete
- 3: No test result with given ID
Data type: String
|
|
output
|
Output describing the status.Data type: String
|
The following example shows how get result status of a completed test check request.
```
var testCheckStatusJson = handler.getTestResultStatus("testResultId");
gs.info(JSON.stringify(testCheckStatusJson));
```
## AgentNowHandler - runCheckForCis\(Object cis, Object check, Number priority, Number timeout\)
Runs a check against the given configuration item.
|
Name
|
Type
|
Description
|
|---|
|
cis
|
[GlideRecord](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md)
|
GlideRecord of any CMDB table \(any application, host, or agent\) that the check is working against.
|
|
check
|
Object
|
Check ID and optional check parameters. ```
"check": {
"checkDefId": "String",
"params": {Object}
}
```
|
|
check.checkDefId
|
String
|
Sys\_id of a check definition in the Check Definitions \[sn\_agent\_check\_def\] table.
|
|
check.params
|
Object
|
Optional. Map of parameter names and values. These settings can be used to override the parameter records of the check definition and its specified values. ```
"params": {
"": "String"
}
```
|
|
priority
|
Number
|
Priority of the request to be set on the ECC queue. Possible values:
- 0: interactive
- 1: expedited
- 2: standard
|
|
timeout
|
Number
|
Value of the timeout for the request in seconds.
|
|Type|Description|
|----|-----------|
|String|Sys\_id of the generated background check request.|
The following example shows how to run a background check and get its request ID.
```
var handler = new sn_agent.AgentNowHandler();
var check = {checkDefId: "028fcd5067c80010b7b72dbd2685ef4f"};
var computerGr = new GlideRecord("cmdb_ci_computer");
computerGr.query();
var requestId = handler.runCheckForCis(computerGr, check, 0, 60);
gs.info(requestId);
```
Output:
```
b9cf14aedb5e30106f4810284b961990
```
## AgentNowHandler - stopBackgroundCheck\(String requestId\)
Stops a background check.
To start a background check, use the runCheckForCis\(\) method.
|Name|Type|Description|
|----|----|-----------|
|requestId|String|The ID of a background check request generated by calling the runCheckForCis\(\) method.|
|Type|Description|
|----|-----------|
|None| |
The following example shows how stop executing a background check.
```
handler.stopBackgroundCheck(backRequestId);
```