HI All
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2024 09:02 PM
Hi All,
I Have one question Related to scheduled job.
i wan trigger scheduled job every year jan month first moday.
I Have write condition
function checkmonday() {
var gdt = new GlideDateTime();
var day = gdt.getDayOfWeek();
var month = parseInt(gdt.getMonth());
var week = gdt.getDayOfMonth();
var result = false;
if (getDayOfWeek == 2 && getDayOfMonth <= 7 && month == 0) { //2 is monday 0 is jan month
gs.info('Today is the first Tuesday of the month.');
} else {
gs.info('Today is the not first Tuesday of the month.');
}
result = true;
}
checkmonday();
but it is trigger every month but we need yearly once that first monday of the year
can any one suggest
Thanks
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2024 10:20 PM
Hi,
I see some issue with the script. Use the below script
Note: I feel Monday represents 1, but you are using 2 in the script. Hope you tested
function checkmonday() {
var gdt = new GlideDateTime();
var day_week = gdt.getDayOfWeek();
var day_month = gdt.getDayOfMonth();
var month = parseInt(gdt.getMonth());
var week = gdt.getDayOfMonth();
var result = false;
if (day_week == 2 && day_month <= 7 && month == 0) { //2 is monday 0 is jan month
gs.info('Today is the first Tuesday of the month.');
result = true;
} else {
gs.info('Today is the not first Tuesday of the month.');
}
}
checkmonday();
Thank you,
Palani
Palani