How to create a scheduled job to only run once a year
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 02:34 AM
Im working on a scheduled job that only needs to run on jan 1 each year, is this correct:
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 04:16 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2025 08:34 AM
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?
Thanks,
Hema
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 04:18 AM
Hello,
Please configure it as below:-
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 05:49 AM
Hello,
If my answer worked for you please mark it as correct as well.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 06:16 AM
does this also set to only go when the clock is 01:00?