How can we run the Schedule job in a specific schedule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2025 05:25 AM
How can we run the Schedule job in a specific schedule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2025 05:45 AM
you cannot.
Example: You configured job to run periodically every 1 hour and your schedule is 8am to 5pm, to control schedule job runs only at that time and not at 6pm you can use Conditional script and see if the current date/time falls in schedule or not, if yes then allow job to run.
Schedule table - cmn_schedule
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2025 09:26 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2025 05:55 AM
You can use a flow and create a custom 'check if in schedule' action. Input as the date to check (current time?) and the schedule you need to check. Then you can use this script as the script step and create a 'true/false' output to let the flow know if you are within the schedule (and if not, don't do whatever it is you want it to do):
(function execute(inputs, outputs) {
var dt = new GlideDateTime(inputs.dateTime); // get as input from flow, like 'sys_created_on' or whatever you need
var sched = new GlideSchedule(inputs.schedule.sys_id); // select the schedule you want to check
if (sched.isInSchedule(dt)){
outputs.is_in_schedule = true;
}
else{
outputs.is_in_schedule = false;
}
})(inputs, outputs);
You can also do the same by using a flow variable, but this action makes it reusable in every flow.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2025 10:25 PM
I have created this schedule job to daily activate catalog link at 5pm EST and deactivate link at 8am EST. Please mark helpful if found useful.
//code to deactivate link
var item = new GlideRecord('sc_cat_item');
if (item.get('88f0cc381bf0de50254e54ea234bcbc9')) { // Replace with actual sys_id
item.active = false;
item.update();
}
gs.info("Form deactivated at 8 AM EST. Will re-open at 5 PM EST");
var item2 = new GlideRecord('sp_rectangle_menu_item');
if
(item2.get('5a293bb887fc96901137fc88cebb35f4')) { // Replace with actual sys_id
item2.active = false;
item2.update();
}
//code to activate link
var item = new GlideRecord('sc_cat_item');
if (item.get('88f0cc381bf0de50254e54ea234bcbc9')) { // Replace with actual sys_id
item.active = true;
item.update();
}
gs.info("Form activated at 5 PM EST. Will close at 8 AM EST");
var item2 = new GlideRecord('sp_rectangle_menu_item');
if
(item2.get('5a293bb887fc96901137fc88cebb35f4')) { // Replace with actual sys_id
item2.active = true;
item2.update();
}