How to Run a Quick discovery from run script in workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2022 11:47 PM - edited 12-26-2022 02:29 AM
I'm trying to Take IP address as input from user in Service catalog and pass it into script which i created in action of flow designer to run a quick discovery. If Device is discovered, i want discovery information (IP Address, Device Name, Class, URL to Discovery CI) in return. Till now i have able to run discovery script and get statusid in return but not able to get discovery information.I have added my code below.Can anyone help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2022 12:41 AM - edited 12-26-2022 12:55 AM
If you are able to run the quick discovery then you should use a wait for condition until this quick discovery finishes.
PFA the status record, your flow should wait it is comepleted
Once this is completed, try fetch the ci detail.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 04:56 AM - edited 12-27-2022 04:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 05:06 AM
After the execution of the attached script.
Get the sys_id of Discovery Status record.
After this you need to lookup discovery_status table with the sys_id=from previous step.
And Apply the wait for condition here to state as Completed.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 05:45 AM
Hi @supareub ,
To run a quick discovery from a script in a workflow in ServiceNow, you can use the new DiscoveryQuickScan()
method. This method returns an instance of the DiscoveryQuickScan class, which you can use to specify the target IP addresses or network ranges to scan, and to start and stop the scan.
Here is an example of how you can use this method in a script step in a workflow:
// Create a new DiscoveryQuickScan object
var scan = new DiscoveryQuickScan();
// Set the target IP addresses or network ranges to scan
scan.setTargets("10.0.0.0/8");
// Start the scan
scan.startScan();
// Wait for the scan to complete
gs.sleep(30000); // wait 30 seconds
// Stop the scan
scan.stopScan();
This example creates a new DiscoveryQuickScan object, sets the target IP addresses or network ranges to scan, starts the scan, waits for 30 seconds, and then stops the scan. You can adjust the wait time to suit your needs, or use a loop to check the status of the scan and wait until it has completed.