Name
sn_agent.CronUtilsForACC
Description
No description available
Script
var CronUtilsForACC = Class.create();
CronUtilsForACC.prototype = {
initialize: function() {
},
isCronUsedInTable : function(tableName, cronSysId) {
var tableGr = new GlideRecord(tableName);
tableGr.addQuery("cron_expressions", "CONTAINS", cronSysId);
tableGr.query();
if (tableGr.next())
return true;
return false;
},
refreshPoliciesOfChangedCron : function(cronSysId) {
var policyIdsToUpdate = {} ;
//search for checks that use cron expressions, and collect their policies ids
var checkInstanceGr = new GlideRecord("sn_agent_check");
checkInstanceGr.addQuery("is_draft", "false");
checkInstanceGr.addQuery("cron_expressions", "CONTAINS", cronSysId);
checkInstanceGr.query();
while (checkInstanceGr.next()) {
policyIdsToUpdate[checkInstanceGr.getValue("monitoring_policy")] = true;
}
// search for policies that use cron expressions directly
var policyGr = new GlideRecord("sn_agent_policy");
policyGr.addQuery("is_draft", "false");
policyGr.addQuery("cron_expressions", "CONTAINS", cronSysId);
policyGr.query();
while (policyGr.next()) {
policyIdsToUpdate[policyGr.getValue("sys_id")] = true;
}
// need to change updated time, so that policies will be re-synced to mid
if(Object.keys(policyIdsToUpdate).length > 0) {
var clientsGr = new GlideRecord("sn_agent_policy_clients");
clientsGr.addQuery("policy", Object.keys(policyIdsToUpdate));
clientsGr.setValue("sys_updated_on", new GlideDateTime());
clientsGr.setWorkflow(false);
clientsGr.updateMultiple();
}
},
type: 'CronUtilsForACC'
};
Sys ID
0c84cedbb752a010ff78dc55ce11a95d