- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2024 07:39 AM
Hi all, how to run a scheduled job every 'month' second 'week' 'monday'.
can someone suggest the conditional script for this. Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2024 07:56 AM - edited ‎08-01-2024 08:17 AM
-
Navigate to the Scheduled Jobs Module:
- Go to System Definition > Scheduled Jobs.
-
Create a New Scheduled Job:
- Click on the New button to create a new scheduled job.
-
Configure the Job:
- Name: Give your job a meaningful name.
- Run: Select Weekly from the dropdown. Set Monday in day
- Time: Set the specific time you want the job to run.
- Day of Month: Since you want the job to run on the Monday of the second week of the month, you'll need to use a script to handle this.
Here is the script
var now = new GlideDateTime();
var dayOfMonth = now.getDayOfMonthLocalTime();
var dayOfWeek = now.getDayOfWeekLocalTime(); // 1=Monday, 2=Tuesday, ..., 7=Sunday
// Check if it's the second Monday of the month
if (dayOfWeek == 1 && dayOfMonth >= 8 && dayOfMonth <= 14) {
// Your job logic here
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2024 08:19 AM - edited ‎08-01-2024 08:20 AM
Hi @SAM321 ,
Select daily in scheduled job and condition would become true only on 2nd tuesday of every month using below script
function checksecondstuesday() {
var gdt = new GlideDateTime();
var day = gdt.getDayOfWeek();
var result = true;
if (day == 2 && (gdt.getDate() >7 && gdt.getDate()<=14)){
result = true;
}
return result;
}
Plz mark my solution as Accept, If you find it helpful.
Thanks & Regards,
Sumanth meda
checksecondstuesday();