How to create a scheduled job to only run once a year

asd22
Tera Contributor

Im working on a scheduled job that only needs to run on jan 1 each year, is this correct:
find_real_file.png

13 REPLIES 13

Hi asd

be careful with the time field and read first the following article: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0782227

Kind regards
Maik

Hi @Maik Skoddow 

 

Will this scheduled job run only once in a year? However I'm getting only 2 options for DateTime function in our instance as getMonthLocalTime() and getMonthUTC(). Will it work?

HemamaniP_0-1751297539098.png

 

Thanks,

Hema

Saurav11
Kilo Patron
Kilo Patron

Hello,

Please configure it as below:-

find_real_file.png

The script you need to right in the condition is:-

 

answer = checkCondition();

function checkCondition(){
var gdt = new GlideDateTime();
var month = gdt.getMonthLocalTime();
var dayOfMonth = gdt.getDayOfMonthLocalTime();

// if month equals to 1 i.e. January
if(month == 1){

if(dayOfMonth == 1){
return true;
}
else{
return false;
}
}
}

 

Please mark answer correct/helpful based on impact.

Hello,

If my answer worked for you please mark it as correct as well.

Thanks.

asd22
Tera Contributor

does this also set to only go when the clock is 01:00?