Need to run a scheduled job on every 2nd Monday in every month.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2021 10:16 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2021 11:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 01:38 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 02:02 AM
Hi,
I tried with daily, if I change day in script but it is still running daily.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 02:17 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader