- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hi All,
I need to modify an existing schedule job for email notifications to run only on weekdays but without a code change on production. And would business calendar help in achieving this in any way? Please see the attached screenshot.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @ShubhankarK9612 ,
why don't you use Run as weekly and check Monday to Friday - this should work
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @ShubhankarK9612 ,
I don't think so. The earliest you test is tomorrow, since it's the weekend
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hello @ShubhankarK9612 ,
There's no real way for you to schedule this script on weekdays without changing the code. You need to add the condition by clicking the conditional checkbox.
You can add a below script -
(function() {
var gdt = new GlideDateTime();
// Get the day of the week (1=Monday, 7=Sunday)
var day = gdt.getDayOfWeekLocalTime();
// Check if today is Saturday (6) or Sunday (7)
if (day == 6 || day == 7) {
return false; // Do not run the job on weekends
} else {
return true; // Run the job on weekdays
}
})();If the script returns true, the job will run , if false the rob will not execute.
If my response has helped you, kindly mark it as helpful and accept the solution.
Regards,
Nayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago - last edited 5 hours ago
Hey @nayanmule ,
Hang on there are ways to do this!
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
If you are on Zurich then you can do this with simple config
Zurich's new run types for scheduled jobs
If not on Zurich then you need to add script in condition field of your scheduled job
answer = checkCondition();
function checkCondition() {
var gdt = new GlideDateTime();
var dayOfWeek = gdt.getDayOfWeekLocalTime();
// day is not saturday and not sunday
if (dayOfWeek != 6 && dayOfWeek != 7)
return true;
else
return false;
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Thank you for the response