function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GunnerGunner 

Business hours for custom objects

Has anyone devised a method for calculating business hours for a custom object?

 

We have processes that are outside of the Case functionality that we need to calculate business hours for but we have not found a way to accurately do this. 

 

does anyone have a formual or have you devised a method to calculate the hours? 

 

werewolfwerewolf
You can add a lookup field on your custom object that looks up to Business Hours.  Then you can just use the built-in Apex Business Hours functions to do your calculations.
tr2121tr2121

Thanks werewolf.  Have you done something similar before?  The piece I am having trouble with is devising a formula or using code to perform the calculations.  Do you have a formula or sample code that does this sort of calculation?

 

 

werewolfwerewolf
Have a look at the docs for the Business Hours class in Apex.  It's really quite simple.  If you use that class, it will also factor in holidays, which is nice.