How to schedule a report to be sent on weekdays?

JC S_
Mega Guru

Would adding a script on the Condition box (when Conditional is checked) achieve this? We don't want to set up 5 different Weekly scheduled reports as much as possible so we want to just setup 1 scheduled report then perhaps add a script on the Condition to limit it on sending only on weekdays.

1 ACCEPTED SOLUTION

prajaktanaik
Giga Expert

Hi Jimboy,



If you dont have a schedule defined, you could also use below script:



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 and so on..


answer = true;


}


return answer;



}



checkWeekday();



Regards,


Prajakta



PS - Hit Like, Helpful or Correct Answer based on the impact of the response!


View solution in original post

4 REPLIES 4

prajaktanaik
Giga Expert

Hi Jimboy,



You can schedule a report daily and put the below script in condition if you have a weekday schedule defined in the system:



function checkWeekdays() {


//var now = new Date();


var day = now.getDay();


var result = false;


var s = new Packages.com.glide.schedules.Schedule("put your schedule sys_id here");  


      var gdt = new GlideDateTime();  



if(s.isInSchedule(gdt, "put your schedule name here") ) {



result = true;


}


return result;


}


checkWeekdays();



Regards,


Prajakta



PS - Hit Like, Helpful or Correct Answer based on the impact of the response!


Packages.com.glide.schedules.Schedule can be replaced with GlideSchedule


prajaktanaik
Giga Expert

Hi Jimboy,



If you dont have a schedule defined, you could also use below script:



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 and so on..


answer = true;


}


return answer;



}



checkWeekday();



Regards,


Prajakta



PS - Hit Like, Helpful or Correct Answer based on the impact of the response!


Hi Prajakta,



Tested this and it is working great. Thanks!