Scheduled Job Condition - First Monday of Every Month

tyler_ford
Giga Contributor

I have a number of tasks that I am looking to assign to IT members using scheduled jobs in Service Now.   I would like to create a monthly schedule that will run on the first Monday of every month as most do not work on weekends.   Has anybody had success creating a schedule like this?    

1 ACCEPTED SOLUTION

Right, but the requirement is for the first Monday of the month.   The isFirstDayOfWeek method simply tells you if it is a Monday or not.



This condition should work:


new Date().getDay() == 1 && new Date().getDate() <=7



It checks to see if it is a Monday (new Date().getDay() == 1) and if it is less than or equal to 7 days into the month (new Date().getDate() <=7).


View solution in original post

20 REPLIES 20

Sudeepta
Tera Contributor

function checkmonday() {


var gdt = new GlideDateTime();


var day = gdt.getDayOfWeek();



var result = false;


  if (day == 1 && gdt.getDayOfMonth()<=7){


  result = true;


  }


  return result;


}


checkmonday();



The above code works for me for creating new HR cases.