Script not working in scheduled reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2025 10:27 PM - edited 06-04-2025 10:30 PM
Hi Team,
Good Day !
I wrote a script in Scheduled report and it's not working and when I run same script in background script it's working fine.
The scenario is a scheduled report that is supposed to run on the second Monday of each quarter . However, it is incorrectly triggering on the first Monday of every week.
I am attaching the script and background script executions as well.
Please check and do the needful !
Thanks & Regards,
Sai Sireesha G
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 02:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 01:14 AM
Please try
getMonthLocalTime()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 12:29 AM
Hi,
Some pointers.
You wanted the report to run on the second Monday of every quarter.
But you've scheduled it to run on a monthly basis (on the first day of each month).
So, in my head, when the report runs, and it's not the correct date, you will not run it again later that month, because next run execution would be the following month.
Therefore I suggest you change the execution to run weekly on Mondays instead.
In the script, check if it is the right month, and the right week. That should be it.
And also, I would wrap the entire script in a function, and set the answer variable as a result of the function call.
Example below.
answer = checkDate();
// Only run on the first month of each quarter, and only on the second monday of that month
function checkDate(){
var gdt = new GlideDateTime();
var month = gdt.getMonth();
var dayMonth = gdt.getDayOfMonth();
if ((month == 1 || month == 4 || month == 7 || month == 10) && dayMonth > 7 && dayMonth <= 14){
return true;
}
else{
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 02:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2025 11:38 PM - edited 06-05-2025 12:25 AM
Hi @Sireesha7 ,
you script looks good
just change the Run to Daily or Weekly from Monthly
if configured weekly like above you can use script (weekly on mondays)
var gdt = new GlideDate();
var day = gdt.getDayOfMonthNoTZ()
var month = gdt.getMonthNoTZ()
answer = (day > 7 && day < 14) && (month == 1 || month == 4 || month == 7 || month == 10);
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya