Conditional scheduled reports - Days of the week
I thought I'd share with you a handy script which is easily adapted to meet yours or your end users needs when it comes to sending scheduled reports.In my past experience and I've been guilty of this is if someone requests a daily report which also gets sent out on non working days, people query but inevitably live with it... Or if you're dedicated you have 5 or so scheduled entries set up for different days.
If you use the below script you can control the days of the week it gets sent out (9am is just an example)
function checkWeekday(){
var today = new GlideDateTime();
var dayOfWeek = today.getDayOfWeek();
var answer = false;
if(dayOfWeek == 1 || dayOfWeek == 2 || dayOfWeek == 3 || dayOfWeek == 4 || dayOfWeek == 5){
//1 - Monday 2 - Tuesday 3 - Wednesday etc... etc...
answer = true;
}
return answer;
}
checkWeekday();
So for example an example if an end user needs a report Monday, Wednesday and Friday this would be 1, 3 and 5.
Labels:
https://www.servicenow.com/community/developer-articles/conditional-scheduled-reports-days-of-the-week/ta-p/2323860
