---
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


---

# StartDiscovery - Global

# StartDiscovery - Global {#ariaid-title1}

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

The StartDiscovery script include provides methods to start discovery jobs.

Use this script include during the discovery scanning phase.

## StartDiscovery - addAdditionalIP(String status, String ip, String sensor) {#ariaid-title2}

Adds an IP (or comma-separated list of IPs) to an existing discovery (used by networks
discovery).
{#r_SDY-addAdditionalIP_S_S_S__table_zdv_1dv_tt__entry__3}

| Name | Type | Description |
|-|-|-|
| status | String | The discovery status |
| ip | String | An IP address, or a comma-separated list of IP addresses. |
| sensor | String | The discovery sensor |
[Table 1. Parameters]

{#r_SDY-addAdditionalIP_S_S_S__table_zdv_1dv_tt} {#r_SDY-addAdditionalIP_S_S_S__table_a2v_1dv_tt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 2. Returns]

{#r_SDY-addAdditionalIP_S_S_S__table_a2v_1dv_tt}

## StartDiscovery - discoverFromSchedule(String ip, Boolean samePhase, String sensor) {#ariaid-title3}

Handles discovery of devices (whether basic or advanced) from a schedule.
{#r_SDY-discoverFromSchedule_S_B_S__table_cq1_xdv_tt__entry__3}

| Name | Type | Description |
|-|-|-|
| ip | String | An IP address, or a comma-separated list of IP addresses. |
| samePhase | Boolean |   |
| sensor | String | The discovery sensor |
[Table 3. Parameters]

{#r_SDY-discoverFromSchedule_S_B_S__table_cq1_xdv_tt} {#r_SDY-discoverFromSchedule_S_B_S__table_dq1_xdv_tt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 4. Returns]

{#r_SDY-discoverFromSchedule_S_B_S__table_dq1_xdv_tt}

## StartDiscovery - getCancelScript() {#ariaid-title4}

Returns the cancel script.
{#r_SDY-getCancelScript__table_idb_t2v_tt__entry__3}

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

{#r_SDY-getCancelScript__table_idb_t2v_tt} {#r_SDY-getCancelScript__table_jdb_t2v_tt__entry__2}

| Type | Description |
|-|-|
| String | The cancel script |
[Table 6. Returns]

{#r_SDY-getCancelScript__table_jdb_t2v_tt}

## StartDiscovery - scheduleCancelJob() {#ariaid-title5}

If the schedule specifies a cancel time, if necessary, schedules a job to cancel the
discovery.
{#r_SDY-scheduleCancelJob__table_smg_l2v_tt__entry__3}

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

{#r_SDY-scheduleCancelJob__table_smg_l2v_tt} {#r_SDY-scheduleCancelJob__table_tmg_l2v_tt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 8. Returns]

{#r_SDY-scheduleCancelJob__table_tmg_l2v_tt}  
The following example shows how to use the scheduleCancelJob() method to cancel a current discovery job.

    var discoveryScheduleGR = new GlideRecord('discovery_schedule'); // Create a discovery schedule Gliderecord
    discoveryScheduleGR.get('name', 'Disco'); // Put the discovery schedule job name

    var discoverySchedule = new DiscoverySchedule(discoveryScheduleGR); 
    var discoveryStatusSysId = new StartDiscovery().startFromIP(discoverySchedule, '172.167.31.231'); // Initiate discovery
    gs.info(discoveryStatusSysId); // Display the sys_id of the discovery status record

    discoveryStatusSysId.scheduleCancelJob(); // Schedule a cancel job, located in the sys_trigger table

Output:

    Operation	Table		Row Count
    insert		discovery_result	1
    update		discovery_status	1
    insert		sys_trigger	     1
    insert		discovery_status	1
    *** Script: Fired started event for: undefined Disco
    *** Script: Scheduling Discovery DIS0010023 for cancellation at 2022-02-13 16:42:44
    *** Script: 1828b05f1b6d811070cb96c6b04bcb53

## StartDiscovery - startFromIP(DiscoverySchedule schedule, String ip) {#ariaid-title6}

Starts a discovery for a single IP using the specified schedule to get information such
as MID servers and behaviors.
{#r_SDY-startFromIP_DS_S__table_elc_1cv_tt__entry__3}

| Name | Type | Description |
|-|-|-|
| schedule | DiscoverySchedule | DiscoverySchedule instance for the schedule to use. |
| ip | String | IP address to discover. Format: dot-formatted string |
[Table 9. Parameters]

{#r_SDY-startFromIP_DS_S__table_elc_1cv_tt} {#r_SDY-startFromIP_DS_S__table_flc_1cv_tt__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the status record created. |
[Table 10. Returns]

{#r_SDY-startFromIP_DS_S__table_flc_1cv_tt}  
This example uses the startFromIP() method to obtain the record that
contains the discover information.

    // Get a discovery schedule gliderecord
    var discoveryScheduleGR = new GlideRecord('discovery_schedule'); 
    discoveryScheduleGR.get('name', 'Discover Management Range 172.x.x.x');

    // Create a DiscoverySchedule object to get information such as MID servers and behaviors
    var discoverySchedule = new DiscoverySchedule(discoveryScheduleGR); 
    var discoveryStatusSysId = new StartDiscovery().startFromIP(discoverySchedule, '172.1.1.10');
     
    // Sys_id of the genterated status record
    gs.info(discoveryStatusSysId);

Output:

    9d3c1197c611228701cd1d94bc32d76d

## StartDiscovery - startFromSchedule(GlideRecord schedule, GlideRecord job) {#ariaid-title7}

Invoked by the discovery script include to kick off a scheduled (or discover now)
discovery.
{#r_SDY-startFromSchedule_GR_GR__table_fgm_jbv_tt__entry__3}

| Name | Type | Description |
|-|-|-|
| schedule | GlideRecord | The instance of discovery_schedule that this discovery is based on. |
| job | GlideRecord | The instance of sys_trigger that triggered this discovery. |
[Table 11. Parameters]

{#r_SDY-startFromSchedule_GR_GR__table_fgm_jbv_tt} {#r_SDY-startFromSchedule_GR_GR__table_ggm_jbv_tt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 12. Returns]

{#r_SDY-startFromSchedule_GR_GR__table_ggm_jbv_tt}

