- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2017 04:06 AM
Hi everyone,
Please help!
Even though in the scheduled job "Control attestation nightly run" which runs daily at 00:00:00 hours, according to it, the controls in review/monitor state should return to attest state as per the frequency set. It is the OOTB(Out of the Box) functionality. But, currently it's not happening and the state of the control is not getting changed.
The script in the scheduled job is :
var control = new GlideRecord("sn_compliance_control");
control.addQuery('state', 'IN', 'review,monitor');
control.query();
var now = new GlideDateTime();
while(control.next()) {
// Get the time of the last attestation
var attestationQ = new GlideRecord('asmt_assessment_instance_question');
attestationQ.addQuery('source_id', control.getUniqueValue());
attestationQ.orderByDesc('sys_updated_on');
attestationQ.query();
if(attestationQ.next()) {
var frequency = control.profile.attestation_frequency + '';
var lastAttested = new GlideDateTime(attestationQ.sys_updated_on + '');
switch(frequency) {
case 'daily':
lastAttested.addDaysUTC(1);
break;
case 'weekly':
lastAttested.addWeeksUTC(1);
break;
case 'monthly':
lastAttested.addMonthsUTC(1);
break;
case 'quarterly':
lastAttested.addMonthsUTC(3);
break;
case 'semi_annually':
lastAttested.addMonthsUTC(6);
break;
case 'annually':
lastAttested.addYearsUTC(1);
}
if(now >= lastAttested) {
control.state = 'attest';
control.update();
}
}
}
But the controls having frequency "daily" and in review/monitor state are not changing back to "attest" state after the execution of the scheduled job.
Please help and share anything that is needed more to accomplish this.
Regards,
Avijeet
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2017 05:10 AM
Hi Avijeet,
I had the same question and I believe I have found out what is happening.
If you look at the script you will see that when it checks the frequency it is not checking the 'frequency' of the control, but rather the 'attestation_frequency' of the profile.
By changing this line:
var frequency = control.profile.attestation_frequency + '';
To:
var frequency = control.frequency + '';
It should now set the control to attest based on the frequency of the control.
I have added 2 screenshots to show you the field on the Control form and on the Profile form.
Profile Form: Note the Attestation Frequency field.
Control Form: Note the Frequency field.
I have raised a HI ticket with ServiceNow asking if this is intended behaviour and will update this post when I get a response.
Regards,
Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2019 10:16 PM
Hi Graham,
Thanks for sharing - I have been wondering about this as well.
The Profile form in Madrid no longer has the Frequency field visible and it does seem as though checking the Frequency on the Control table is more consistent with the design - why have the Frequency field on Control otherwise?
Looks to me as though ServiceNow might want to look at this again with a view to changing the scheduled job as suggested above.
thanks .. John