How to schedule a scheduled job only on weekdays?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 05:00 AM
How to schedule a scheduled job only on weekdays?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2021 06:21 AM
Hi,
I want my schedule to run 1st of every quarter month, which should exclude if 1st falls on a weekend and run the job the next working day so if I use the below will the schedule job just skip if it's a weekend or will it run the next working day.
var gdt = new GlideDateTime();
var dow = gdt.getDayOfWeekLocalTime();
if (dow < 6) {
if (gdt.getMonth() == 1 || gdt.getMonth() == 4 || gdt.getMonth() == 7 || gdt.getMonth() == 10) {
answer = true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2017 05:29 AM
Hi Swathi,
In Scheduled Jobs please enable the Condition checkbox and paste the below code.
var answer = false;
var now = new GlideDateTime();
if(now.getDayOfWeekUTC() !=6 && now.getDayOfWeekUTC() !=7 ) // this scheduled job will run only on Weekdays
{
answer = true;
}
Please Hit Like, Helpful or Correct depending on the impact of response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2024 11:11 AM
This conditional script works, running Washington DC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2024 11:28 AM
Hello @swathigangadhar ,
Could you try this script and let me know if it works or not?
var answer = false;
var now = new GlideDateTime();
if(now.getDayOfWeek() > 0 && now.getDayOfWeek() < 6){
answer = true;
}
Thank you.
If you think this script will help you please like this.