Schedule report on the 1st day on the month excluding weekends
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 01:39 AM
How to schedule a report for every 1st of month but if it is weekend then it should trigger next day.
12 REPLIES 12

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2022 10:05 AM
Hi St,
To use Scheduled Reports, set it up to run Daily and set the condition as follows.
var answer = false;
var gdt = new GlideDateTime();
var curDay = gdt.getDayOfMonthUTC(); // current day of month
gdt.setValue(gs.beginningOfThisMonth());
var dow = gdt.getDayOfWeek();
var firstDay = 1; // default to run report on 1st
if (dow == 6) { // if Sat, run report on 3rd
firstDay = 3;
} else if (dow == 7) { // if Sun, run report on 2nd
firstDay = 2;
}
if (curDay == firstDay) { // check if current day is the day to run report
answer = true;
}
answer;

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 02:08 AM
Hello ST,
Try like this.? Mark my answer as correct if that helps
Code:
//Return 'true' to run the job
var answer = false;
//Get the day of week. 1=Monday, 7=Sunday
var now = new GlideDateTime();
//Run only on weekdays
if(now.getDayOfWeek() < 6){
answer = true;
}
answer;
Please hit like and mark my response as correct if that helps
Regards,
Musab
Regards,
Musab
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 02:36 AM
Hi Rasheed,
For example- 1st may was Sunday.. so the scheduling will get excluded ...will it then schedule for 2nd May?