logo

NJP

Shortcut to test Instance Scan Column Type Check / Linter Checks within seconds

Import · May 03, 2021 · article

Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

Hi there,

Working on Instance Scan, and creating your own Scan Checks? Great! Though have you noticed, testing Scan Checks of type Column Type Check and Linter Check, take minutes? On an out-of-the-box instance this could be about 5 or 6 minutes, while on larger / older instances this could be easily 15 minutes or more. You might also have noticed this in the Live Coding Happy Hour which we did on Instance Scan. We tried performing a Linter Check, though didn't get to the result due to the time it runs image.

A short article to share how to take a shortcut while testing the Column Type Check and Linter Check for Instance Scan.

Test Check

Out-of-the-box, a UI Action is available on Scan Checks which displays a form button called "Test Check". Basically, this executes a full instance scan just using the Test Check the user is currently on. A pretty nice out-of-the-box feature. The only thing, this test will take several minutes.

image

So how can we shorten the test time involved, when performing a Test Check? For example, you created a Linter Check, and wanting to test if it works, if the syntax is okay, testing a small adjustment, etc, how to shorten the test time?

Shortcut: Run Point Scan

Out-of-the-box, on Tables extended from sys_metadata, UI Action "Run Point Scan" is available on (active) records as a related link. Basically, this executes all scan checks against only the Process record the is currently on.

image

Let's say you're Linter Check is about checking for "new Object()" usage in the script (is a JavaScript bad practice), you could create a temporary Business Rule or Fix Script for example which contains "new Object()" in the Script field and perform the UI Action "Run Point Scan". While the Test Check performs a full instance scan and takes minutes, the Run Point Scan only checks the current record and just takes seconds! Your shortcut to test within seconds image.

Note: The UI Action does contain a condition, with amongst others "new sn_instance_scan.ScanUtil().isScannable(current)". I haven't found out the exact details in this yet, as we cannot access sn_instance_scan.

---

And that's it, hope you like it.

Kind regards,

Mar k Roethof

ServiceNow Technical Platform Architect @ Quint Technology

2x ServiceNow Developer MVP

2x ServiceNow Community MVP

---

View original source

https://www.servicenow.com/community/developer-articles/shortcut-to-test-instance-scan-column-type-check-linter-checks/ta-p/2296705