Need to run a scheduled job on every 2nd Monday in every month.

Mallika4
Tera Contributor

Hello Developers!

I am trying to run a scheduled job for every 2nd Monday in every month.

Can anyone help me on that?

Thanks in advance!

8 REPLIES 8

Hi,

In Run field which needs to select on scheduled job for every 2nd monday in every month?

find_real_file.pngThanks in advance!

Hi,

Set the Run as Daily

Since you are already having script to check if today is 2nd monday of month so no issues

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi,

I tried with daily, if I change day in script but it is still running daily.

 

Hi,

the job would trigger daily but the script would only execute when condition becomes true

condition would become true only on 2nd monday of every month using below script

answer = checkCondition();

function checkCondition(){

	var gdt = new GlideDateTime();
	if((gdt.getDayOfMonthLocalTime() >= 8 && gdt.getDayOfMonthLocalTime() <= 14) && (gdt.getDayOfWeekLocalTime() == 1)) {
		return true;
	}
	else{
		return false;
	}

}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader