
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
05-24-2021 10:16 PM - edited 08-12-2024 09:07 AM
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
Hi there,
Sometimes you just need to verify if a certain Date/Time is within a Schedule or not. Browsing the ServiceNow Community you will come across several (good) solutions. Ideally you would have such a solution available in such a way, that you can re-use it easily. For example using a Script Include, or… Flow Designer action!
GlideSchedule API
Key of verifying if a Date/Time is within a Schedule is the "GlideSchedule" API. There are several functions for this API, though we are specifically interested in "isInSchedule". Looking at the Docs, usage could be something like:
var sched = new GlideSchedule(schedule_sys_id);
var date = new GlideDateTime();
if(sched.isInSchedule(date))
gs.info("Is in the schedule");
else
gs.info("Is NOT in the schedule");
Action
We just need to transform the script mentioned, into a Flow Designer Action. Just adding that the Schedule and Date/Time could be provided as inputs to make the Action dynamic and that the Action returns an output which represents if the Date/Time provided is within the provided Schedule.
Inputs could be:
Outputs could be:
Using the inputs and outputs we've set up, the Script step could be something like:
Now simply save and publish the Action!
Schedule
Sure, obviously you do need to have a Schedule available. If this concerns a Date/Time check for within working hours of a workday Schedule, just have a look if your company already has such a Schedule.
Though what If you would like to check if the Date/Time is on a workday, not specifically within the working hours? You could solve this with some complex scripting, or… just creating a new Schedule. A new Schedule, which would have the same days and child (holiday) Schedule as your regular workday Schedule. The only difference that this new Schedule does not run from 9 AM till 5 PM, though 24 hours.
Result
Within a Flow Designer Flow or Subflow, you would now have the possibility to add the Action created.
Output of the Action would be a true/false boolean.
For example you could now verify if a Date/Time field from a queried record, is within a Schedule. Because the Date/Time field is not mandatory (and by default the current Date/Time) you could also use this Action to verify if when the Flow is running, is within a Schedule.
Share
An Update Set with this Flow Designer Action can be downloaded from Share:
- Flow Designer Action "Verify Inside Schedule"
---
And that's it actually. If any questions or remarks, let me know!
C |
If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.
Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in? |
Kind regards,
Mark Roethof
ServiceNow Technical Platform Architect @ Quint Technology
2x ServiceNow Developer MVP
2x ServiceNow Community MVP
---
- 6,988 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very useful, love it!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks Mark - just what we needed. Quick note to anyone else who stumbles on this thread - still working as of Sept 2023.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I'm facing the below issue could you please provide any help.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you for this Mark. Extremely helpful, no longer need to work with 'wait for duration of time' to get this functionality working.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Mark Roethof The schedule_sys_id is the sys id of the schedule or scheduled entry?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Mark Roethof This flow action doesnt work for me. I have utilised your update set and tested it in flow designer.
Below is my schedule.
When I test it with the sys id of the schedule (not the scheduled entry) I get the below results which is incorrect. Could you suggest what am doing wrong?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@VarunS same for me the action is not working any solution u got?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
The action does work for me. What I did notice is that schedule entries need to have nothing set in the "Type" field for it to work. When previously populated with a value, it doesn't work.
Admittedly, not sure this is the same as the issue you have but just sharing in case.
Paul