Scheduled Flow on Workdays

Mark Roethof
Tera Patron
Tera Patron

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

LinkedIn

1 ACCEPTED SOLUTION

Andrew Albury-D
Mega Guru

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: 
find_real_file.png

 

And the Script Step to check:

find_real_file.png

 

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:

find_real_file.png

 

 

Hope that helps!

-Andrew

View solution in original post

6 REPLIES 6

Hey Mark, I've just whipped up an article about this (as I've done the increment days stuff before!)

Check it out:

https://community.servicenow.com/community?id=community_article&sys_id=79f51f7bdbc2109066f1d9d968961...

❤️

Hi @Andrew Albury-Dor,

This is really cool and is something that I have been trying to get working for my company. 

My business problem is as follows. I want to send a SMS out on Incidents that are created after Core business hours. 

I created a new schedule (Out of hours 19:00:00 to 07:00:00) which looks like the following,

find_real_file.png

I have then followed your notes above by creating the Action 

find_real_file.png

find_real_file.pngfind_real_file.png

 

In my flow I am now doing the following 

find_real_file.png

The Input time I have based this on the Created Date / Time of the INC and not the Run Start time of the Trigger. I tried this but still get the same results.

find_real_file.png

find_real_file.png

The issue that I am having is that every priority 1 INC that I am creating is going down the TRUE path regardless of the time. Example I created a P1 INC before 19:00:00 this should evaluate to FALSE but it's not. 

been stuck on this today and would appreciate some thoughts 

 

Kind Regards 

Mark