- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 09:27 PM
Hi,
How to get first Monday/ Tuesday/Wednesday/Thursday of every month for scheduling the report.
I need to scheduled the report first Monday of every month.
I have tried below script it's working but there is error here that take a example : I have scheduled one report it has to be generate on second Tuesday midnight every month but it's generated first Tuesday of the month. Ex: April 7th 2020 is First Tuesday of the month and I need the report should generate on second Tuesday of the month means 14th April 2020. Please help me on this if there is any thing need to change.
var prefixes = ['First', 'Second', 'Third', 'Fourth', 'Fifth'];
var result;
var gdt = new GlideDateTime();
var day = gdt.getDayOfWeek();
var week = gdt.getDayOfMonthLocalTime();
result = true;
} else {
result = false;
}
return result;
}
checkSecondTuesday();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 09:41 PM
Hi Jry,
Try below code to get first monday of every month:
function checkmonday() {
var gdt = new GlideDateTime();
var day = gdt.getDayOfWeek();
var result = false;
if (day == 1 && gdt.getDayOfMonth()<=7){
result = true;
}
return result;
}
checkmonday();
Refer this link below, it might help you to solve it out:
If my answer helped you in any way, mark answer as helpful and correct.
Thanks and regards,
Megha.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2020 06:57 AM
The best solution would be to create a schedule, where you definitely have more control and a lot more options to define your recurrence.
Then in your Scheduled Job you just use the scripted option and just check if the current date is within your schedule.
Something like this:
new GlideSchedule("<yourschedule.sys_id>").isInSchedule(new GlideDateTime())
The next level and much more elegant solution, would be to customize the Schedule Job form in order to allow you to select your schedule that will be used in the recurrence.