cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

So you just want Flow running in business hours - 8am to 5pm

Here is a little helper I use when creating flows that I only want running during business hours only.

 

Let's say we generate an hourly email that goes to shared mailbox. There are times when this email is pointless after 6pm or before 8am (per say). There are times when there is no need to have this email outwith Monday to Friday so here is an easy way to handle that.

 

Capture-203.PNG

 

 

Retrun true if after 8am but before 5pm

 

@and(greaterOrEquals(formatDateTime(utcnow(),'HH:mm'), '''08:00'''), lessOrEquals(formatDateTime(utcnow(),'HH:mm'), '''17:00'''))

Return true if not Saturday or Sunday

 

@or(not(equals(formatDateTime(utcnow(),'dddd'), '''Saturday''')), not(equals(formatDateTime(utcnow(),'dddd'), '''Sunday''')))

When either of the above returns false I like to the "Terminate" action to complete Flow as a success.

 

Capture-204.PNG

 

 

Both of the above conditions have the same "Terminate" action with in. So once you satisfy the conditions the Flow can now push on and do something useful.

 

If this post helps you, please help the community by clicking thumbs up.

 

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


7 REPLIES 7
DynamicGanesh
Level: Powered On

Re: So you just want Flow running in business hours - 8am to 5pm

Hi @AlanPs1 , thanks for sharing this. Very helpful. Smiley Happy

Does this mean the flow runs every hour within those business hours? The interval attribute suggests it runs once every hour between 8am to 5pm.

I'm looking to achieve something similar but want to leave the flow snoozing outside business hours and keep it running continuously between 8am to 5pm.

Super User
Super User

Re: So you just want Flow running in business hours - 8am to 5pm

Hi @DynamicGanesh , thank you for your reply.

You're right, it runs every hour on the hour. The start time helps it run on the hour. This doesn't snooze or delay but for example, if it runs outwith the hours of 8am to 5pm the Flow terminates as a success and does no more as it is aware it is out of hours.

 

Info posted here also - https://www.alanps1.io/power-platform/so-you-just-want-flow-running-in-business-hours-8am-to-5pm/

 

Adding a delay could be a neat enhancement actually so it'd be nice to see how you customise this to acheive that. I posted this as I used the method to generate an hourly report of live O365 service health issues and there was no need to have the update arrive in a shared mailbox outwith these hours as there was no-one there to read it at those times. It finished at 5pm and started again at 8am the next morning.

 

If you find my posts helpful, please mark with thumbs up

 

Any questions, just ask.

 

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


DynamicGanesh
Level: Powered On

Re: So you just want Flow running in business hours - 8am to 5pm

@AlanPs1  Thanks Alan, appreciate your quick response. I'll have to tweak my approach a bit now. The scenario we have is:

 

We've got a flow running on SQL row update trigger for a SQL database table to send emails based on certain SQL field values/conditions. It runs perfectly fine but now we also have added a stored procedure (running overnight outside of business hours) which is also updating this table.

 

We do not want the flow to trigger for these updates (as there will be thousands of unncessary flow runs) which is why I was curious about your solution to ignore the SQL updates occurring outside of business hours.

 

The real limitation with Flow is conditionally triggering a flow based on update of certain attributes/fields. Smiley Sad I'll post here if I'm able to solve it.  

DynamicGanesh
Level: Powered On

Re: So you just want Flow running in business hours - 8am to 5pm

@AlanPs1 I'm considering a Flow Management or Microsoft Flow for Admin connector action (plus recurrence/timer) to achieve this. Both offer options to control other flows running within an environment.

jab365
Level: Powered On

Re: So you just want Flow running in business hours - 8am to 5pm

Awesome stuff, i look.forwaed to giving this a go!

Given that flow is consumption based have you found a way to schedule it within those hours and not consume an execution?

I'm probably splitting hairs but wanted to check 😁
Gabegia
Level: Powered On

Re: So you just want Flow running in business hours - 8am to 5pm

First off, thanks for this @AlanPs1 !  Just the logic I was looking for.

 

I took it one step further by adding the logic to the Recurrence trigger criteria rather than a condition statement, so the flow doesn't even trigger outside the business hours (saving Flow runs & keeping the run log cleaner).

 

2019-10-30_0844.png

 2019-10-30_0845.png

 

I want mine to run on the weekends as well as weekdays (just 8-5), but you could also combine the two queries just by adding the "or" statement as a third condition to the "and".

@and(greaterOrEquals(formatDateTime(utcnow(),'HH:mm'), '''08:00'''), lessOrEquals(formatDateTime(utcnow(),'HH:mm'), '''17:00'''),or(not(equals(formatDateTime(utcnow(),'dddd'), '''Saturday''')), not(equals(formatDateTime(utcnow(),'dddd'), '''Sunday'''))))

 

Gabe

Super User
Super User

Re: So you just want Flow running in business hours - 8am to 5pm

Great use of Trigger conditions @Gabegia 

 

Thank you for coming back to post your enhanced approach.

 

#CommunityRocks !


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users Online
Currently online: 201 members 6,420 guests
Please welcome our newest community members: