Instance Scan IntegrationHub Spokes (“Execute Comb... - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

Hi there,

During the Live Coding Happy Hour of June 3rd, we jumped into automating Instance Scan. Looking into the available out-of-the-box REST APIs, the available out-of-the-box IntegrationHub Spokes, and we've created one IntegrationHub Spoke ourselves. After the show, I've also created two other IntegrationHub Spokes so that there is an IntegrationHub Spoke for every out-of-the-box endpoint.

A short sum-up and of course, the created IntegrationHub Spokes free to download.


new sn_instance_scan.ScanInstance()

There are some out-of-the-box scripting possibilities to execute Scans on your own ServiceNow instance. Scripting using out-of-the-box Script Include "ScanInstance" and its functions. I've written an article on this particular topic before:
- Automating the different Instance Scan scan types


REST API's

While watching one of the Creator Toolbox episodes, at some point Andrew Barnes showed the Continuous Integration/Continuous Delivery (CI/CD) API Docs page. A page containing amongst others several Health Scan endpoints (the wording has been updated to Instance Scan). It's a bit hidden, you won't find the Instance Scan endpoints that quickly or being mentioned in loads of documentation… though that Docs page is really awesome!

Six out-of-the-box Instance Scan endpoints are described, most of them you will get up and running quite quickly. Only the "Scoped Apps" and "Update Sets" endpoints can be a bit more tricky to get up and running. The trick for those two, the Request body parameters. An example for the "Scoped Apps" endpoint:

{
    app_scope_sys_ids: ["String", "String", "String"]
}

Note that this is a little bit different than the example on the Docs. Without the curly braces, this won't work.


IntegrationHub Spokes

So that's a nice out-of-the-box API and endpoints available. We could like to use this now within scripting, Business Rules, Script Includes, etcetera. Or, what about Flow Designer, can we create some nice re-usable Actions (Spokes)?

Well actually… jumping into Flow Designer, looking at the out-of-the-box available Actions, already three Spokes for Instance Scan are available (Instance Scan Execute Full Scan, Instance Scan Execute Point Scan, and Get Instance Scan Results)! It's just the same as the Instance Scan endpoints… It's a bit hidden, you won't find these Instance Scan spokes that quickly or being mentioned in loads of documentation. While there is a useful Continuous Integration and Continuous Delivery (CICD) Spoke Docs page.

Once you've set up a Credential Alias, getting the three out-of-the-box Instance Scan spokes up and running is a matter of seconds. Just drag-and-dropable components, providing some inputs, and that's it. Setting up integrations can't get easier than this!


Execute Combo Scan, Execute Scoped Apps Scan, Execute Update Sets Scan

During the Live Coding Happy Hour episode, we shortly looked at the missing Spokes. There are six endpoints and only three spokes. The missing ones:
- Execute Combo Scan;
- Execute Scoped Apps Scan;
- Execute Update Sets Scan.

During the episode, we copied the "Execute Point Scan" spoke and turned this into a "Execute Update Sets" Scan spoke. Almost everything of the copied spoke can be re-used, of course the inputs are a little bit different. The "biggest" differences are on the REST step, the Resource Path, and the Request Body. The request body can be tricky as mentioned with the REST endpoints, though the basics would be something like:

find_real_file.png

You might discuss on the input of the "Update Set Sys Ids". How are these provided? Will this be a string, with comma-separated Sys Ids? Or will this be an array object? The Request Body does expect an array object. For the "Execute Update Sets" spoke we worked on, we choose a string. In that case, you would need to apply some Pre Processing on the "Update Set Sys Ids" or apply a Transform Function, like splitting the string so it becomes an array object.

find_real_file.png

Another approach could be to provide the input directly as an object. The input then also being of type Array. Obviously, the Flow or Subflow where you are applying this spoke, does need to have an Array already available to provide as input.


Result

Three re-usable, drag and droppable IntegrationHub Spokes to integrate Instance Scan on other Instances within minutes!

find_real_file.png


Share

While re-creating this Spoke (and the other two missing Spokes), will only take about 15 minutes, I've also uploaded these Spokes to Share, free to download:
- Instance Scan IntegrationHub Spokes

---


And that's it, hope you like it.

👍
If this post helped you in any way, I would appreciate it if you hit bookmark or mark it as helpful.

Interested in more articles, blogs, videos, and Share Projects on Instance Scan I published?
Instance Scan


Kind regards,
Mark
2020-2021 ServiceNow Community MVP
2020-2021 ServiceNow Developer MVP

---

LinkedIn

Version history
Last update:
‎06-16-2021 09:56 PM
Updated by: