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!
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:
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.
@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.