Scheduled Jobs... no "Yearly" option!?

Droid101
Kilo Explorer

I technically need quarterly, but since that's not an option, my next best is creating four events, one each quarter, that repeat yearly. But there's no option for yearly!

Periodically 365 days would be a fine replacement, but I don't want to have to go in and fix it every four years when leap year rolls around.

Can we enable yearly? Or will I be creating an extra scheduled job that goes off every 1460 days to remind me to fix the other ones? 🙂

6 REPLIES 6

Mark Stanger
Giga Sage

You could set up a scheduled job like this...

http://www.servicenowguru.com/system-definition/weekdaysonly-scheduled-job/

You would just have to change it so that the scheduled job ran monthly and then modify your conditional script to check for the month using 'getMonth' instead of 'getDayOfWeek' as shown in the script listed on SNCGuru.


Nice find! However... I'm getting errors. I put in this script:

//Return 'true' to run the job
var answer = false;

//Get the month of the year. 1=January, 12=December
var now = new Packages.com.glide.glideobject.GlideDateTime();

//Run only quarterly
if(now.getMonth() = 1 || 4 || 7 || 10){
answer = true;
}
answer;

And I'm getting this error:

Error:

Problem at line 8 character 20: Expected ')' to match '(' from line 8 and instead saw '='.

if(now.getMonth() = 1 || 4 || 7 || 10){

Problem at line 8 character 22: Missing '{' before '1'.

if(now.getMonth() = 1 || 4 || 7 || 10){

Problem at line 8 character 37: Expected an assignment or function call and instead saw an expression.

if(now.getMonth() = 1 || 4 || 7 || 10){

Problem at line 8 character 39: Missing ';'

if(now.getMonth() = 1 || 4 || 7 || 10){

Problem at line 8 character 39: Expected an identifier and instead saw ')'.

if(now.getMonth() = 1 || 4 || 7 || 10){


You need to do this for your 'if' condition.



now = now.getMonth();
if(now == 1 || now == 4 || now == 7 || now == 10){


Thanks for the quick responses. I changed it to:


//Return 'true' to run the job
var answer = false;

//Get the month of the year. 1=January, 12=December
var now = new Packages.com.glide.glideobject.GlideDateTime();

//Run only quarterly
now = now.getMonth();
if(now == 1 || now == 4 || now == 7 || now == 10){
answer = true;
}
answer;


But get the error:


Problem at line 12 character 2: Expected an assignment or function call and instead saw an expression.

answer;


I assume we don't need "answer" at the end, since the if statement returns answer as true, setting off the condition?