---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# AgentNowHandler - Scoped

# AgentNowHandler - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

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://www.servicenow.com/docs/access?context=acc-landing-page&version=xanadu&pubname=xanadu-it-operations-management&ft:locale=en-US).

For the REST API solution, refer to [Agent Client Collector API](https://servicenow-prod.fluidtopics.net/VqZ3eXHD4gCQogGcocPm9A#agnt_clnt_cll-api "The Agent Client Collector API provides endpoints to manage actions on available agents and managing policies.").

## AgentNowHandler - AgentNowHandler() {#ariaid-title2}

Creates an AgentNowHandler instance.
{#AgentNowHnl-AgentNowHandler__table_ohr_4qd_bpb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#AgentNowHnl-AgentNowHandler__table_ohr_4qd_bpb}  
The following example shows how to initialize AgentNowHandler.

    var handler = new sn_agent.AgentNowHandler();

## AgentNowHandler - getRequestStatus(String requestId) {#ariaid-title3}

Gets status of the request with the given ID.
{#AgentNowHnl-getRequestStatus_S__table_zk2_2g2_z4b__entry__3}

| Name | Type | Description |
|-|-|-|
| requestId | String | A check request ID generated by calling the runCheckForCis() method. |
[Table 2. Parameters]

{#AgentNowHnl-getRequestStatus_S__table_zk2_2g2_z4b} {#AgentNowHnl-getRequestStatus_S__table_al2_2g2_z4b__entry__2}

| 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. {#AgentNowHnl-getRequestStatus_S__ul_edm_1rr_5qb} 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. {#AgentNowHnl-getRequestStatus_S__ul_qcf_zcq_5qb} Data type: String |
[Table 3. Returns]

{#AgentNowHnl-getRequestStatus_S__table_al2_2g2_z4b}  
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) {#ariaid-title4}

Gets the test check status of the given test result.
{#AgentNowHnl-getTestResultStatus_S__table_zk2_2g2_z4b__entry__3}

| Name | Type | Description |
|-|-|-|
| testResultId | String | A test result ID generated by creating a test check request. |
[Table 4. Parameters]

{#AgentNowHnl-getTestResultStatus_S__table_zk2_2g2_z4b} {#AgentNowHnl-getTestResultStatus_S__table_al2_2g2_z4b__entry__2}

| Properties | Description |
|-|-|
| status | Status of the test results. Possible values: * 0: Pending * 1: In progress * 2: Complete * 3: No test result with given ID {#AgentNowHnl-getTestResultStatus_S__ul_yyq_4bq_5qb} Data type: String |
| output | Output describing the status. Data type: String |
[Table 5. Returns]

{#AgentNowHnl-getTestResultStatus_S__table_al2_2g2_z4b}  
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) {#ariaid-title5}

Runs a check against the given configuration item.
{#AgentNowHnl-runCheckForCis_O_O_N_N__table_zk2_2g2_z4b__entry__3}{#AgentNowHnl-runCheckForCis_O_O_N_N__agntNowHlr-parm-ph-chkparms}

| Name | Type | Description |
|-|-|-|
| cis | [GlideRecord](https://servicenow-prod.fluidtopics.net/Z64TK~kWnpWTEG5bCPvZuQ#c_GlideRecordScopedAPI "The scoped GlideRecord API is used for database operations.") | GlideRecord of any CMDB table (any application, host, or agent) that the check is working against. |
| check | Object | Check ID and optional check parameters. { "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": { "<parameter name>": "String" } {#AgentNowHnl-runCheckForCis_O_O_N_N__agntNowHlr-parm-cd-chkparms} |
| priority | Number | Priority of the request to be set on the ECC queue. Possible values: * 0: interactive * 1: expedited * 2: standard {#AgentNowHnl-runCheckForCis_O_O_N_N__ul_bkf_hnq_wqb} |
| timeout | Number | Value of the timeout for the request in seconds. |
[Table 6. Parameters]

{#AgentNowHnl-runCheckForCis_O_O_N_N__table_zk2_2g2_z4b} {#AgentNowHnl-runCheckForCis_O_O_N_N__table_al2_2g2_z4b__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the generated background check request. |
[Table 7. Returns]

{#AgentNowHnl-runCheckForCis_O_O_N_N__table_al2_2g2_z4b}  
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) {#ariaid-title6}

Stops a background check.
To start a background check, use the runCheckForCis() method.
{#AgentNowHnl-stopBackgroundCheck_S__table_zk2_2g2_z4b__entry__3}

| Name | Type | Description |
|-|-|-|
| requestId | String | The ID of a background check request generated by calling the runCheckForCis() method. |
[Table 8. Parameters]

{#AgentNowHnl-stopBackgroundCheck_S__table_zk2_2g2_z4b} {#AgentNowHnl-stopBackgroundCheck_S__table_al2_2g2_z4b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 9. Returns]

{#AgentNowHnl-stopBackgroundCheck_S__table_al2_2g2_z4b}  
The following example shows how stop executing a background check.

    handler.stopBackgroundCheck(backRequestId);


