GRC : How to set collection frequency of Indicator templates/Indicators to bi-weekly

Majji Koteswar1
Tera Expert

Hi Team,

 

We have got a requirement to run the indicator templates/indicators bi-weekly which we don't have the option in OOB. Could someone kindly provide guidance to achieve this with best practice?

 

Thanks,

Majji

3 REPLIES 3

Mark Dooley
Tera Contributor
So you want to run your GRC indicator templates every two weeks, but you're staring at the standard options in ServiceNow and wondering why "bi-weekly" isn't just there? Yeah, you're not crazy. It's just not an out-of-the-box (OOB) option. But no worries, there are options.
 
One idea is to create a Scheduled Script Job (under "Scheduled Script Executions"),  give it a name like "Bi-weekly GRC Indicator Runner", have it run periodically, with repeat interval as custom ( maybe set it to every 14 days or use “weekly” and pick every other Monday) and choose a time when the system isn't slammed (like 3:00 AM)
 
In the Advanced tab, try this:
(function executeBiWeeklyGRC() {
    try {
        var templateGR = new GlideRecord('grc_indicator_template');
        templateGR.addQuery('active', true);
        // Optional: Only run templates marked for bi-weekly runs
        // templateGR.addQuery('u_biweekly', true);
        templateGR.query();
 
        while (templateGR.next()) {
            var indicator = new GRCIndicator();
            indicator.runIndicatorsFromTemplate(templateGR.sys_id);
            gs.info('[Bi-Weekly GRC] Ran indicators for template: ' + templateGR.name);
        }
    } catch (e) {
        gs.error('[Bi-Weekly GRC] Error during execution: ' + e.message);
    }
})();
 
Some other tips: You can test this in Background Scripts first, just to make sure things don’t go off the rails. One other thought might be to add a custom filter for this so it only runs the biweekly things, vs all active templates - (e.g., in the grc_indicator_template table, you would create a new boolean field for biweekly and check it so only biweekly template run)
 
Good luck!

Hi @Mark Dooley 

 

Thank you very much for the response. I have gone through the script you provided. However, I didn't find GRCIndicator() class. Can you please confirm which class and function to be used exactly in the lines below?

 
var indicator = new GRCIndicator();
indicator.runIndicatorsFromTemplate(templateGR.sys_id);
 
Thanks,
Majji

Mark Dooley
Tera Contributor
My bad — GRCIndicator() is not a documented or out-of-the-box global class in ServiceNow. The function call runIndicatorsFromTemplate() doesn’t exist in any officially documented GRC API as of recent versions either. Its actually custom code from the instance I was looking at. If you added the custom boolean field  its in the table grc_indicator_template (and assume the field is called "u_biweekly_run" you can use the updated script below (and then the templateGr.name would be the template you are pointing to, etc, etc)
 
(function executeBiWeeklyGRC() {
    try {
        var templateGR = new GlideRecord('grc_indicator_template');
        templateGR.addQuery('active', true);
        templateGR.addQuery('u_biweekly_run', true); // Optional: only run bi-weekly templates
        templateGR.query();
 
        var processor = new sn_grc.GRCIndicatorTemplateProcessor();
 
        while (templateGR.next()) {
            // Log which template you're working on
            gs.info('[Bi-Weekly GRC] Running indicators for: ' + templateGR.name);
 
            // Generate indicators from template
            processor.generateIndicatorsFromTemplate(templateGR.sys_id);
        }
    } catch (e) {
        gs.error('[Bi-Weekly GRC] Error during execution: ' + e.message);
    }
})();