ProfessorFlow
ActionBase Pack

Business Hours Toolkit

Complete suite of four Flow invocable actions for business-hours-aware date calculations, time differences, schedule checks, and next-open-date lookups.

v1.0.0Updated yesterday

Overview

The Business Hours Toolkit bundles four Salesforce Flow invocable actions into a single deployable package. Together they give your Flows complete control over Salesforce Business Hours — adding time, measuring elapsed time, checking whether a moment is inside working hours, and finding the next open window.

Each action wraps a native BusinessHours platform method and exposes it as a no-code Flow action. All four respect your org's Business Hours configuration including holidays, so SLA calculations, scheduling logic, and after-hours routing work correctly out of the box.

What's Included

ActionWhat It DoesPlatform Method
Add Business HoursAdds a time interval while only counting working hoursBusinessHours.add()
Calculate Business Hours DifferenceMeasures elapsed time between two DateTimes in business hours onlyBusinessHours.diff()
Calculate Is Inside Business HoursChecks if a DateTime falls within active business hoursBusinessHours.isWithin()
Calculate Next Business DateFinds the next DateTime when business hours are openBusinessHours.nextStartDate()

When to Install the Toolkit

  • You need two or more of these actions — the toolkit deploys all four in one step
  • You're building SLA-aware automation that requires multiple business hours calculations
  • You want a single source of truth for all business hours logic in your org

When to Install Individual Actions Instead

User Guide

Getting Started

  1. Ensure you have a Business Hours record configured in Setup (Setup > Company Settings > Business Hours)
  2. Note the Business Hours Id — every action in this toolkit requires it as an input
  3. Deploy the toolkit to your org using the SFDX command below
  4. In Flow Builder, search for "Professor Flow" to find all four actions
  5. Drag any action onto your canvas and map the Business Hours Id and DateTime inputs

Actions Quick Reference

Add Business Hours

Input3 attributes
startDateTimeRequired
DateTime

The DateTime to start from

businessHoursIdRequired
Text

The record Id of the Business Hours to use

intervalMillisecondsRequired
Number

Time interval to add, in milliseconds

Output1 attribute
updatedBusinessDate
DateTime

The resulting DateTime after adding the interval during business hours only

Calculate Business Hours Difference

Input3 attributes
businessHoursIdRequired
Text

The record Id of the Business Hours to use

startDateRequired
DateTime

The beginning of the time range to measure

endDateRequired
DateTime

The end of the time range to measure

Output3 attributes
diffResult
Number

Difference in milliseconds, counting only business hours

diffResultSec
Number

Difference in seconds, counting only business hours

diffResultMin
Number

Difference in minutes, counting only business hours

Calculate Is Inside Business Hours

Input2 attributes
givenDateTimeRequired
DateTime

The DateTime to evaluate

businessHoursIdRequired
Text

The record Id of the Business Hours to check against

Output1 attribute
dateInsideBusinessHours
Boolean

True if the DateTime falls inside business hours; false otherwise

Calculate Next Business Date

Input2 attributes
givenDateTimeRequired
DateTime

The DateTime to start searching from. Returned as-is if already within business hours.

businessHoursIdRequired
Text

The record Id of the Business Hours to evaluate against

Output1 attribute
nextAvailableBusinessDate
DateTime

The next DateTime when business hours are open

Common Patterns

SLA Deadline Calculation: Use Add Business Hours to project a deadline from case creation, then Calculate Is Inside Business Hours to verify follow-ups land during working hours.

Elapsed Time Reporting: Use Calculate Business Hours Difference between two milestones (e.g., case created vs. case resolved) to get actual working-hours duration for SLA compliance dashboards.

Smart Scheduling: Use Calculate Next Business Date to ensure automated tasks, notifications, or assignments only trigger during open hours. Pair with Calculate Is Inside Business Hours for conditional routing.

Troubleshooting

  • "Business Hours Id is required" — Every action requires a valid Business Hours record Id. Query it from the BusinessHours object or hardcode a known Id in a Flow constant.
  • Results seem off by a day — DateTime values are timezone-sensitive. The Add Business Hours action returns results in the running user's local time zone. Verify your org's timezone settings match expectations.
  • Holidays not being respected — Ensure holidays are associated with the correct Business Hours record in Setup. Only holidays linked to the specific Business Hours Id you pass will be factored in.

Code

The toolkit repo contains all four actions and their test classes in a standard SFDX project structure:

force-app/main/default/classes/
├── addBusinessHours.cls              — Add time interval during business hours
├── addBusinessHoursTest.cls          — Test class
├── CalculateBusinessHoursDiff.cls    — Measure elapsed business hours
├── CalculateBusinessHoursDiffTest.cls— Test class
├── calculateIsInsideBusinessHours.cls — Check if DateTime is in business hours
├── calculateIsInsideBusinessHoursTest.cls — Test class
├── CalculateNextBusinessDate.cls     — Find next open business date
└── CalculateNextBusinessDateTest.cls — Test class

Deploy the entire toolkit with a single command:

sf project deploy start --source-dir force-app

All classes use API version 66.0 (Spring '26) and the global access modifier for Flow visibility.

Release History

Search

Search components, articles, and tags