top of page
  • Writer's pictureChris

Calculate Business Hours Diff In Flow Builder

Updated: Mar 19, 2020

Effective key performance indicators are a valuable part of any business. However, Salesforce does not have an easy declarative way to do calculations around business hours. You can do this with a variety of formula fields, but it is not very flexible.


For example, how do you quickly update it for a snow day, or your leadership team approved an extra holiday over the winter break? At my organization, we wanted to track performance indicators such as how long does it take to make our first attempt and how long does it take to make the first contact.


This new flow action will allow you to quickly and easily calculate the business hours between two dates. This utilizes the Salesforce built-in Business Hours object. The component has three inputs:

  • Business Hours Id

  • Start Date

  • End Date

You will have the option to output the difference in milliseconds, seconds, or minutes.


Enjoy this action!


Installation

Coming Soon

  1. A flow action to determine if a date is within business hours

  2. A flow action to determine the next business date for a given date

  3. A flow action to add an interval of time from a start Datetime traversing business hours only.

Resources

10,002 views30 comments

Recent Posts

See All

30 Comments


nithin gowda
nithin gowda
Mar 15

Is it an open source, Is there a chance of data security issue.


Like

Adam McChesney
Adam McChesney
Jan 29

Hello @Chris ! Does this Action take into account Daylight Savings Time at all? We are currently calculating our time to first response on Cases using formulas, but due to DST happening on different dates each year, our formulas are off by 1 hour for about half the year. Will this Action solve that, or will it face the same issue?

Like
Chris V
Chris V
Jan 29
Replying to

This does solve for that specific problem. Its one of the specific use cases I developed this for.

Like

Ed Sobotka
Ed Sobotka
Dec 27, 2023

@Chris Is this package ICU Locale Format compatible? SF is switching to ICU rather than JDK in the Spring '24 release and that will obviously cause issues with Date/Time fields.

Like
Chris V
Chris V
Dec 27, 2023
Replying to

Yes, it works with ICU Locale Format as well.

Like

andyginnau
Feb 21, 2023

Hi @Chris


Just checking the Output variables, getting the below error which looks to be field time. Basically i'm using a number variable as the output then assigning it to a number field on my case object

  • We can't save this record because the “Business Hours” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to update records: INVALID_TYPE_ON_FIELD_IN_RECORD: Case Age Minutes (BH): value not of required type: -7951. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1918530843-96663 (808797769)ook up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1918530843-96663 (808797769)

Like
andyginnau
Feb 21, 2023
Replying to

Thanks, not sure what the issue might be as the output from the apex class action is a number right? And I’m passing it to another number field

Like

Anne Gaudin
Anne Gaudin
Feb 20, 2023

Hi @Chris ,

I have also an issue but I can't figure it out :

The flow tried to update these records: 5003X00002hCdkQQAS. This error occurred: FIELD_FILTER_VALIDATION_EXCEPTION


Inputs

businessHoursId = 01m3X000000gOHD

endDate = {!$Record.ClosedDate} (26/01/2023 12:31)

startDate = {!$Record.CreatedDate} (23/01/2023 14:03)


Outputs

{!Textminute} = diffResultMin (1497) => my variable is in text then I change it to number.


It would be great if you can help me find what is the issue .. Thank you


Like
Anne Gaudin
Anne Gaudin
Feb 24, 2023
Replying to

I find the solution thank you for your help the discussion helped me a lot ! thank you

Like
bottom of page