- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 12:17 AM
Hi Guys
Would this script work for a condition based on the last working day of the month? running monthly.
function isLastWorkingDay(gdt) {
var today = gdt.getDayOfWeekLocalTime();
var thisMonth = gdt.getMonthLocalTime();
switch (today) {
// Saturday and Sunday are NOT the last working day of the month
case 6:
case 7:
return false;
break;
// If it's a Friday, add 3 and see if the month changes.
case 5:
var nextMonday = gdt;
nextMonday.addDaysLocalTime(3);
var nextMondayMonth = nextMonday.getMonthLocalTime();
return (nextMondayMonth != thisMonth);
break;
}
}
var now = new GlideDateTime();
var lwd = isLastWorkingDay(now);
answer = lw
Also, see highlighted in yellow
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 03:09 AM
var gdt1 = new GlideDateTime();
if(gdt1.getDayOfMonth() >= 11){
var gdt = new GlideDateTime();
gs.log('Rodz triggered script');
var today = gdt.getDayOfWeekLocalTime();
var thisMonth = gdt.getMonthLocalTime();
if(today == 5){
var nextMonday = gdt;
nextMonday.addDaysLocalTime(3);
var nextMondayMonth = nextMonday.getMonthLocalTime();
if(nextMondayMonth != thisMonth){
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 03:09 AM
var gdt1 = new GlideDateTime();
if(gdt1.getDayOfMonth() >= 11){
var gdt = new GlideDateTime();
gs.log('Rodz triggered script');
var today = gdt.getDayOfWeekLocalTime();
var thisMonth = gdt.getMonthLocalTime();
if(today == 5){
var nextMonday = gdt;
nextMonday.addDaysLocalTime(3);
var nextMondayMonth = nextMonday.getMonthLocalTime();
if(nextMondayMonth != thisMonth){
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2022 11:17 PM
After some testing last week, this still hasn't worked
i changed a bit of the code to :
var gdt1 = new GlideDateTime();
if (gdt1.getDayOfMonth() >= 11) {
var now = new GlideDateTime();
var lwd = isLastWorkingDay(now);
gs.info('Log1');
answer = lwd;
gs.info("Log1 : "+answer);
answer;
}
function isLastWorkingDay(gdt) {
gs.log('Rodz triggered script');
var today = gdt.getDayOfWeekLocalTime();
var thisMonth = gdt.getMonthLocalTime();
gs.log("Today : "+today);
switch (today) {
// Saturday and Sunday are NOT the last working day of the month
case 6:
case 7:
gs.log("Log : 1");
return false;
// break;
// If it's a Friday, add 3 and see if the month changes.
case 5:
var nextMonday = gdt;
nextMonday.addDaysLocalTime(3);
var nextMondayMonth = nextMonday.getMonthLocalTime();
gs.log("Log : 2");
return (nextMondayMonth != thisMonth);
// break;
}
}
seems like these is making the condition false