How to Create Scheduled Jobs Only for Weekdays (Monday to Friday)

UdhayakumarS559
Tera Contributor

Hi all,

I want to create Scheduled Jobs in ServiceNow that run only on weekdays (Monday to Friday). As shown in the attached screenshot, I only see options like Daily, Weekly, Monthly, Periodically, etc., but I don’t see any specific setting to restrict the job to only weekdays.

 

UdhayakumarS559_0-1751020876657.png

 

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron

@UdhayakumarS559 

you can use Conditional checkbox and use condition field

When it's weekday set the answer=true and if not then set answer=false

answer = false;
//Get the day of week. 1=Monday, 7=Sunday
var now = new GlideDateTime();
//Run only on weekdays
if (now.getDayOfWeekUTC() < 6) {
    answer = true;
}

AnkurBawiskar_0-1751025801224.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

View solution in original post

3 REPLIES 3

J Siva
Kilo Patron

Hi @UdhayakumarS559 
Check the "Conditional" checkbox and enter the following script in the Condition Script field.

var today = new GlideDateTime();
var day = today.getDayOfWeekLocalTime();
if(day =='6' || day =='7'){ // return 'false' if it's Saturday or Sunday
	return false;
}else{
	return true;
}

Regards,
Siva

Ankur Bawiskar
Tera Patron

@UdhayakumarS559 

you can use Conditional checkbox and use condition field

When it's weekday set the answer=true and if not then set answer=false

answer = false;
//Get the day of week. 1=Monday, 7=Sunday
var now = new GlideDateTime();
//Run only on weekdays
if (now.getDayOfWeekUTC() < 6) {
    answer = true;
}

AnkurBawiskar_0-1751025801224.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.