- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2016 10:20 PM
Do I have to check "glide.schedules.repeat_nth" property and set it to Day??
I also wrote this script:
var now = New DateTime();
var day = now.getDay();
gs.log("Day is :" + " " +day);
if( day == 3)
{
var rec1 = new GlideRecord("incident");
rec1.initialize();
rec1.applyTemplate("Test");
rec1.insert();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2016 11:08 PM
Hi Shreya,
Please find the script to be written in conditional, this should work -
function checkThirdTuesday(workDay){
var ordinals = ["", "1", "2", "3", "4", "5"];
var date = String(new Date());
var tokens = date.split(" ");
var floatNumber = ordinals[Math.ceil(tokens[2]/7)];
var weekDay = tokens[0];
if(floatNumber == "3" && weekDay == workDay)
result = true;
else
result = false;
return result;
}
checkThirdTuesday('Tue');
Hopefully it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2016 10:53 PM
Create a schedule job of run type daily. Make it conditional and in condition use following script
answer = getThirdTuesday();
function getThirdTuesday(){
var dt = new GlideDateTime();
var day = dt.getDayOfWeek();
var dayOfMonth = dt.getDayOfMonth();
if(dayOfMonth < 15 || dayOfMonth > 22){ // 3rd Tuesday will always be between 14 and 23 of month and 2nd or 4th Tuesday cannot lie between these dates
return false ;
}
if(day == 2){ // 2 for Tuesday
return true ;
}
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2016 11:08 PM
Hi Shreya,
Please find the script to be written in conditional, this should work -
function checkThirdTuesday(workDay){
var ordinals = ["", "1", "2", "3", "4", "5"];
var date = String(new Date());
var tokens = date.split(" ");
var floatNumber = ordinals[Math.ceil(tokens[2]/7)];
var weekDay = tokens[0];
if(floatNumber == "3" && weekDay == workDay)
result = true;
else
result = false;
return result;
}
checkThirdTuesday('Tue');
Hopefully it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2016 02:57 AM
Thank you sooooo much .. It actually worked.. Thanks alot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2016 03:04 AM
Its good to know that it has worked, could you please mark the answer as correct, so that it will be helpful for future community users