
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 06:06 AM
Hi all,
I am looking into slowly moving from Scheduled Jobs to Flow Designer. One of the things I can't figure out or might have overlooked... I would expect in Flow Designer just some choice list to appear where you could select a schedule 🙂
How to run a Flow only on workdays?
According to a certain schedule. Is that possible at all with Flow Designer? Or do we need to jump into scripting, Actions, etc. immediately for this... and making using Flow Designer instead of old school Scheduled Jobs actually less worthwhile?
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 03:59 PM
Hey Mark!
I believe the best bet for this one is a custom action I've created to check if a given time is in schedule.
Create the flow with a "Daily" trigger, running every day at your desired time, then as the first action, check if the time the flow started (a data-dot from the trigger) is within a certain schedule. You could create a new schedule if you don't have one already.
Here's the details of the action:
Inputs:
And the Script Step to check:
Here's the code snippet:
(function execute(inputs, outputs) {
if (inputs.time) {
var timeToUse = new GlideDateTime();
timeToUse.setDisplayValue(inputs.time.toString());
} else {
var timeToUse = new GlideDateTime();
}
var sched = new GlideSchedule(inputs.sched.getUniqueValue());
var output = sched.isInSchedule(timeToUse);
outputs.timeInSched = output;
})(inputs, outputs);
Then map the output to a true/false.
Then your flow will look like this:
Hope that helps!
-Andrew

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 09:03 AM
.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 10:54 AM
.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2020 03:59 PM
Hey Mark!
I believe the best bet for this one is a custom action I've created to check if a given time is in schedule.
Create the flow with a "Daily" trigger, running every day at your desired time, then as the first action, check if the time the flow started (a data-dot from the trigger) is within a certain schedule. You could create a new schedule if you don't have one already.
Here's the details of the action:
Inputs:
And the Script Step to check:
Here's the code snippet:
(function execute(inputs, outputs) {
if (inputs.time) {
var timeToUse = new GlideDateTime();
timeToUse.setDisplayValue(inputs.time.toString());
} else {
var timeToUse = new GlideDateTime();
}
var sched = new GlideSchedule(inputs.sched.getUniqueValue());
var output = sched.isInSchedule(timeToUse);
outputs.timeInSched = output;
})(inputs, outputs);
Then map the output to a true/false.
Then your flow will look like this:
Hope that helps!
-Andrew

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2020 12:26 PM
Ha Andrew,
Gnarly nice thought for an Action, all spot on! Only adding a default Schedule. Also gives immediate some ideas for more Actions about Schedules, adding days, etc.. With small generic Actions like these Flow Designer does make more sense than older techniques like Scheduled Jobs.
Tnx!
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field