How to schedule a scheduled job only on weekdays?

swathigangadhar
Tera Expert

How to schedule a scheduled job only on weekdays?

8 REPLIES 8

anjalichoudhary
Kilo Guru

Hi Swathi,



These below links will help you to schedule your schedule job only for weekdays:



Reporting Schedules - Weekdays only




Hope it helps!!



Regards,


Anjali


BALAJI40
Mega Sage

check the run job daily and check the conditional check box


in the advanced script: try the below script


whenToRun();


function whenToRun(){


var day = new Date().getDay();


return (day == 1 || day == 2 || day == 3 ||day == 4 ||day == 5); // or return (day != 0 || day != 6 )


}


Chuck Tomasi
Tera Patron

Have it run every day at the same time. Within your script, you check for the day of the week. If it's not a weekday (2-6), you exit. You can get the day of week with the GlideDateTime() method, getDayOfWeekLocalTime();



var gdt = new GlideDateTime();


var dow = gdt.getDayOfWeekLocalTime();



if (dow < 6) {
        // Do your weekday logic here


}


Minor update to my condition statement. Per documentation:



The day of week value, in the user's time zone, from 1 to 7. Monday equals 1, Sunday equals 7.