Saturday, June 19, 2010

Business Hours SLA in Salesforce workflow

Someone once said, there are two ways to do a job. One is doing smartly and the other is doing hardly.

When it came to implement a requirement, I chose the second way..alas..

The scenario was to calculate End Time of a Start Time not in 24 hours format. I had to exclude weekend, holidays and Non-Business Hours (only Business Hours, say 9am to 6pm taken into consideration).

I tried a hell lot of things, and ended up doing everything my way. JPSeabury did this very thing the salesforce way, the easiest way. You can find it here in his blogpost.

I tried everything in the same order he did. Then I came up with "my" way.
1. Created an object to store Holidays
2. Created another object to store user locales (Time Zones)
3. Created a lot of apex (about 400 lines) to calculate the time elapsed between two times.

Morale: Don't reinvent the wheel


PS: If you have faced a problem like this, please refer to JP's blog.


Happy Clouding...