I feel like this might nicely fit into the „How I solved it“ series, which Jen is running.
A customer came the other day that they have a new process, where they need to follow-up with a new lead in 2 hours and notify owner and their supervisor if there is a delay.
My initial reaction was „damn, cases have it out-of-the-box but that’s not a reason to change leads to cases and it is really pity“
The next thought was pretty simple – 2 hours, it is just a simple flow which would set a date/time field and put extra two hours there and then scheduled path with email/Slack message.
Obviously it turned out to be a bit more complex:
- 2 hours only during business hours
- operating in multiple timezones
In Apex we can use the BusinessHours class, which would solve the check whether we are already after hours or weekend or ban holiday, but do I want to develop this thing? And how to handle the timezones?
And how can I solve it in Flow? Add two hours and check whether it is already after working hours or weekend? That would be complex and ugly to configure.
Invocable classes and community solution to my rescue, I’m so glad that I know UnOfficialSF.com.
The Solution
There are actually two great solutions on the UnOfficialSF, which I combined.
The first is more complex and can solve almost anything, except using specified business hours to run the calculation (it takes the default one)
The second one can take specific business hours into account, but there is no way how to figure out which of them.
- Create a business hours for „each“ timezone – I didn’t really create for each, but only for the timezones (or rather timeshifts?) where present employees are based. What I mean by „timeshifts“? If there are two people, one located in Prague and one in Berlin (both are GMT+1) I would create just one record (e.g. BusinessHours1), where the number means the offset. The potential downside are cities, which typically have the same time shift but sometime to the switch to summer/winter time at different time of the year (or not at all – I still remember some states in Australia have it differently)
- As all times in Salesforce are stored in UTC/GMT the first thing the flow does is to calculate the offset of the owner of the record – the timezone field on user record doesn’t specify the numeric value, but the real city, so we cannot just get it from the record but the Apex can tell me the difference
- We will find the respective business hours record (remember the number in the name) and if there is none we would take the default one
- Calculate the offset via calling the respective method and passing the business hours Id
- Have a second after-save flow with scheduled path – the assumption is that there aren’t that many records created on daily basis to hit the limits of scheduled interviews. The reason for second flow was, that when you update the „Follow-up till“ value in the same flow, the scheduled path is not recalculated. Crucial detail when designing these two flows was also the order of their execution – don’t forget to set it right otherwise it might work just on second save or never

Done!
That would be too quick, right? One of my biggest fear was how to post the message to Slack, especially as I want to mention the respective user. Turned out that when you setup the Slack integration it automatically syncs the Slack user ids (or you can map it manually), so it was simple matter of lookup the user id (and their superior) and add the id into the Slack message – the format of <@Id> has been luckily easy to find on the internet.
Take away
Customer happy and one crucial fact discovered as well – to surprise of everyone, most of the leads could wait till the next day for processing (meaning the 2 hours deadline will be only the next day).
While the intention of assigning the person from the respective region was generally good and made sense, turned out that customers have been typically registering rather at the end of the day/after hours and it might be better to assign them to someone from other region, to really get in touch in those 2 hours. Obviously they might have done it as the last task of their day and be already out of office, but who knows and we don’t have data to confirm that.
What about you, do you have some KPIs to track and automation to help you keep up with them?