Schedule report on first monday of every month
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 12:04 PM
Hi,
I am trying to schedule a report that needs to be sent on first Monday of every month and I have used a below query, Can someone hep me understand whats wrong in the query.
function checkmonday() {
var gdt = new GlideDateTime();
var day = gdt.getDayOfWeek();
var result = false;
if (day == 1 && gdt.getDayOfMonth()<=7){
result = true;
}
return result;
}
checkmonday();
and I have schedule as follow:
RUN: Weekly
Day: Monday
Time : 8:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 12:30 PM
I went thought ever single example of a scheduled report and job that I could find in the system. the only thing I could see is that you have the function coded and then are calling it. Not sure if that will cause the issue but trying doing it like this.
checkmonday();
function checkmonday() {
var gdt = new GlideDateTime();
var day = gdt.getDayOfWeek();
var result = false;
if (day == 1 && gdt.getDayOfMonth()<=7){
result = true;
}
return result;
}
Also I know in the past if have had issues with doing gdt.getDayOfMonth() in an if statement in the past. You may to to put that in a variable like you did for getDayOfWeek.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 05:44 AM
Hi Brian,
I used the code which you have provided, but now the report is sent every week on monday, but I want to schedule it for first Monday of ever month

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 09:13 AM
You may want to put in case with NOW Support. I tried this in my PDI with your code. I also tried doing what
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 05:53 AM
Hi,
you should set answer variable with true or false
I hope you are using condition field to add that script
function checkmonday() {
var gdt = new GlideDateTime();
var day = gdt.getDayOfWeek();
var result = false;
if (day == 1 && gdt.getDayOfMonth()<=7){
result = true;
}
return result;
}
answer = checkmonday();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 07:24 PM
check this link for Orlando version the GlideDateTime doesn't work fine in scheduled report condition field; they have mentioned workaround as well using Date() class of javascript
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader