Branch Workflow based on Time of Day

Hi

I’m looking for a way to branch a workflow based on time of day.

So if the current system time is between 9am and 6pm, the workflow runs immediately.

However if it’s outside those hours, it delays until 9am the next day.

Setting the workflow to only run its actions within those hours isn’t appropriate as the workflow itself has delays etc that need to run in real time, so the option in settings isn’t suitable. I’ve tried to work around it by use comparitors off datetime properties but I only get the option to use days, not hours in terms of “x days ago” so I’m a bit stuck.

Any suggestions on how I can branch a workflow based on the time of day?

Hey @TM-OML what I would probably do is a custom contact property called “time of day”. The first action of your workflow would be “edit record” and set the custom property “time of day” to the date the action completes.

This gives you the time of the day that you can then use to branch on in the next steps!

Hi Tom, I have tried that using a date/time property but the only comparators I get are in days, not hours

Ah! My apologies I forgot about that. @TM-OML hmm, outside of Karstens answer the only thing I could think of would require operations hub to take the time from the datetime and print it to another property.

You could do something like convert the datetime into a string:

Copy the sting to a text field and then use something like “text property contains 9:00” or whatever time to branch your workflow!

Hi @TM-OML,

Have you considered creating separate workflow for each time of the day and scenario? Delays continue to run outside of workflow working hours so I wouldn’t see that as a reason to not use this feature. Only actual actions (anything that’s not a delay) would have to wait.

  • Workflow 1: runs 9am to 6pm
  • Workflow 2: runs 6am to 9am

The exact instructions would depend on the actions you want these workflows to execute – but in the past I found that I could solve all time-of-the-day questions with workflow working hours.

For example, workflow 1 and 2 could also hand over records to another workflow that is not subject to workflow working hours so that actions not bound to a time of the day can execute correctly.

Best regards

Hi Karsten

The problem is I don’t want the delay to run outside of working hours - the delay needs to run inside of working hours

So if the workflow is triggered outside of hours, I just want it to wait until working hours start again, including the delays

@TM-OML wouldn’t this delay type solve for this?

I believe all the building blocks are there but I can’t specify without knowing the exact actions and “rules”.

Hi Karsten, it would work perfectly IF the trigger only occured out of hours

So if the object is created (the trigger) at 10am, I would like the workflow to run straight away.

However if the object is created at 7pm, I would like the workflow to run at 9am

Using the function you suggest above would mean that the object created at 10am would not run until 9am the next day.

Hence why I’m trying to branch based on time of day!

@TM-OML I’m not sure if I’m following. The scenario you described could be solved with one workflow and working hours set from 9am to 5pm. A record entering at 10am would be processed immediately, a record entering at 7pm would have to wait until 9am.

If there are any follow-up actions that could exceed the working hours window (e.g. delays for multiple days), simply set up your original workflow to hand over records to a second workflow that is not bound by time of the day.

In other words, you would have one workflow with working hours that checks if it should hand over records to your actual workflow immediately – or wait until 9am, if a record enters too late in the day. The actual workflow could run without limitations in terms of working hours.

Ah I see, so it would still enrol it would just wait. Right, that makes sense! Thank you. I think that will do what it needs to do!

Tom