Automating Instance Scan on Update Set for current suite

kStoev
Tera Contributor

Hello,

 

I have a question about the automation of the Instance Scan for Update Set. For the moment everything it seems to work fine following the logic that i provided OOB by ServiceNow. The main idea that I had was to create a Subflow that is going to use the logic for the Instance Scan, but I want to be decoupled so the spokes in the Flow Designer are not an option. I have created a Script Include containing the following logic and the idea was to use custom actions and to create a subflow that is going to perform Instance Scan for Update Set at some point. I have added some checks in my new Suite, but I'm not able to pass it in this particular method. 
I saw all topics in the community about the Instance Scans and I saw to following: "Update set scan can’t validate script level check. As of now, update set scan can only validate "table" and "column" level check. This is very much limitation to use this functionality while automation update set scan during our development cycle." - The first question here from my side is, is this true?

And on top of that, when I run the scan, I see the new sys_progress_worker sys_id, but thats all. Nothing appears in the scan_finding table for some reason, and I think this is because I can't pass my Suite with all the checks that I have. 
Again, in one of the community posts, I saw this method getOrCreateComboForSuiteAndTargets

 

 

function getOrCreateCombo() {
		var suiteId = this.getParameter('sysparm_suite_sys_id');
		var targetTable = this.getParameter('sysparm_target_table');
		var targetIds = JSON.parse(this.getParameter('sysparm_target_sys_ids'));

		return new sn_instance_scan.ScanUtil().getOrCreateComboFromSuiteAndTargets(suiteId, targetTable, targetIds);
	}

 

 

Here in this method as you can see, I can pass the SuiteId, but still is this the only way to achieve that, because I want to perform the Instance Scan on one Update Set, but here I need to pass the sys_ids as a targetIds in an Array. 

 

 

function executeScan(func) {
        try {
            return JSON.stringify({
                status: SUCCESS_CODE,
                progressId: func()
            });

        } catch (e) {
            return JSON.stringify({
                status: FAILED_CODE,
                message: e.message
            });
        }
    }

    function collectUsageMetric(event) {
        var sampleMap = new GCFSampleMap();
        sampleMap.put('event_name', '' + event);
        GCFCollector.recordUsageEvent('custom_metric', 'instance_scan_suite', 'instance_scan_suite_event', sampleMap);
    }

    function executeUpdateSetScan(sysId) {
        collectUsageMetric('scan_instance_ajax_update_set_scan');
        return executeScan(function() {
            return new sn_instance_scan.ScanInstance().triggerUpdateSetScan(sysId);
        });
    }

var scanResults = executeUpdateSetScan(current.sys_id);

 

 

Here scanResults is returning the newly created sys_progress_worker sys_id. So in the end, is it possible to pass the suiteId to the normal update set scan and can this be done within an subflow in flow designer? I'm open to suggestions and solutions, if somebody had the same issue.

 

Thanks in advance to all of you for the help!

Regards,

Kalin Stoev

0 REPLIES 0