How to schedule incident every Third Tuesday of each month??? I tried doing it by "Scheduler" and Trigger Type - "Week in month" but it's next action always gives a Monday date .

Sjoshi2
Mega Contributor

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();

}

1 ACCEPTED SOLUTION

ghsrikanth
Tera Guru

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


View solution in original post

18 REPLIES 18

Hi All



Similar request is to run a Job at every month last Saturday. There is a Schedule Job which I need to execute on last Saturday of every month.


Any suggestion..




Regards


Ranjan


slperry92
Kilo Explorer

Thanks Dan, how would I enter the 17 day and 2nd Tuesday without creating another script to call the ManintanaceScedule. Can I just enter those values in the original script?


Hi All


By using same solution how can I get a schedule Job run at Last Saturday of every month? If anyone suggest will be helpful to get information



Regards


Ranjan


function checkSecondFriday(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];



var gdt = new GlideDateTime("Put today's date here"); // use value coming from 'date' variable


gs.info(gdt.getDayOfWeekLocalTime());


var day = gdt.getDayOfWeekLocalTime(); // here you check first date of every month coming on which day



if( day == 1 || day ==2 || day ==3 ||day ==7)   // if first date of a month comes on Monday/Tuesday/Wedneday/Sunday                                                                                                                                                             then 4th saturday is last Saturday


{


      if(floatNumber == "4" && weekDay == workDay)


                    answer = true;


      else


                  answer = false;


return answer;



}


else if( day == 4|| day == 5|| day == 6) // If first date of a month comes on Thursday/Friday/Saturday then 5th Saturday is                                                                                                                                           last saturday


{




  if(floatNumber == "5" && weekDay == workDay)


                    answer = true;


      else


                  answer = false;


      return answer;



}


checkSecondFriday('Sat');




Please hit, like or helpful.