Scheduled report running incorrectly—triggering weekly instead of quarterly

Sireesha7
Tera Contributor

Hello Team,

"I have created a scheduled report that is supposed to run on the second Monday of each quarter for the vulnerability table. However, it is incorrectly triggering on the first Monday of every week. Could you please help me resolve this issue?"

 

Please find the script which i have mentioned in scheduled report

var gdt = new GlideDateTime(); // Creates a new date-time object
var month = gdt.getMonth(); // Extracts the current month (0-based: Jan = 0, Apr = 3, etc.)
var day = gdt.getDayOfMonth(); // Extracts the day of the month
var dayOfWeek = gdt.getDayOfWeek(); // Extracts the day of the week (1 = Monday, 7 = Sunday)

// Check if today is the second Monday of the quarter (Jan, Apr, Jul, Oct)
if (dayOfWeek == 1 && (month == 1 || month == 4 || month == 7 || month == 10) && day > 7 && day <= 14) {
    answer = true; // Set result to true if conditions match
}else{
answer = false; // Set result to false otherwise
}
 
 
Could you please help me?
 
Thanks & Regards,
Sireesha

 

2 REPLIES 2

mohdarbaz
Kilo Guru

Hi @Sireesha7 ,

Try the below code:

var gdt = new GlideDateTime(); // Current date-time
var month = gdt.getMonth(); // 0-based: Jan = 0, Apr = 3, Jul = 6, Oct = 9
var day = gdt.getDayOfMonth(); // Day of the month
var dayOfWeek = gdt.getDayOfWeek(); // 1 = Monday, 7 = Sunday

// Check if today is the second Monday of the quarter (Jan, Apr, Jul, Oct)

//change in below line
if (dayOfWeek == 1 && (month == 0 || month == 3 || month == 6 || month == 9) && day > 7 && day <= 14) {
answer = true;
} else {
answer = false;
}

 

If my response helped, please mark it correct and close the thread so that it benefits future readers.

 

Regards,

Mohd Arbaz.

Hi @mohdarbaz ,

 

Thanks for your response, But unfortunately, the code is not working.

 

Could you please check and do the needful?

 

Thanks & Regards,

Sai Sireesha G