The Zurich release has arrived! Interested in new features and functionalities? Click here for more

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

Dr Atul G- LNG
Tera Patron
Tera Patron

https://www.servicenow.com/community/developer-forum/schedule-job-need-to-trigger-only-on-weekdays/m...

 

check @Harish KM reply in above link

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

Ankur Bawiskar
Tera Patron
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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

https://www.servicenow.com/community/developer-forum/schedule-job-need-to-trigger-only-on-weekdays/m...

 

check @Harish KM reply in above link

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

J Siva
Tera Sage

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
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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader