- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2025 11:44 AM
Hi All,
I have a scheduled job that runs on Monday, Thursday, and Friday.
I also want to add this condition: run every three hours between 7 AM and 4 PM, while keeping the existing days functionality.
How to do that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2025 05:54 AM
@Ankur Bawiskar
Need to run every three hours between 7 AM and 4 PM, not after 4 PM
i used this logic for start-end time with starting time field empty
Is it ok or any suggestion to improve this logic?
var now = new Date();
var dayOfWeek = now.getDay();
var hour = now.getHours();
gs.info('hours '+hour);
var allowedDay = (dayOfWeek >= 1 && dayOfWeek <= 5);
// Only allow between 07:00 and 16:00
var allowedTimeRange = (hour >= 7 && hour < 16);
if(allowedDay && allowedTimeRange) {
answer = true;
}
else {
answer = false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2025 05:57 AM
Nice catch, I forgot to have that.
yes you will have to ensure it stops at 4pm
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
‎08-12-2025 11:44 AM
@Ankur Bawiskar can you please look into this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2025 08:00 PM
for that you need to change like this
Run -> Periodically
Repeat Interval -> 3 hours
Starting Time -> 7 AM
Condition: Same script as above.
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
‎08-13-2025 05:54 AM
@Ankur Bawiskar
Need to run every three hours between 7 AM and 4 PM, not after 4 PM
i used this logic for start-end time with starting time field empty
Is it ok or any suggestion to improve this logic?
var now = new Date();
var dayOfWeek = now.getDay();
var hour = now.getHours();
gs.info('hours '+hour);
var allowedDay = (dayOfWeek >= 1 && dayOfWeek <= 5);
// Only allow between 07:00 and 16:00
var allowedTimeRange = (hour >= 7 && hour < 16);
if(allowedDay && allowedTimeRange) {
answer = true;
}
else {
answer = false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2025 05:57 AM
Nice catch, I forgot to have that.
yes you will have to ensure it stops at 4pm
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