ProfessorFlow
ActionActive

Add Business Hours

Add an interval of time from a start DateTime, traversing business hours only. Returns the next business date.

v1.1.0Updated yesterday

Overview

Add Business Hours is an Apex invocable action that calculates a future DateTime by adding an interval of time while only counting business hours. It wraps Salesforce's native BusinessHours.add() method and exposes it as a Flow-callable action.

This is essential when you need to calculate SLA deadlines, response times, or follow-up dates that respect your organization's business hours configuration.

When to Use This

  • Calculate SLA deadlines that skip weekends and after-hours
  • Determine the next available business date/time from a given start point
  • Build escalation timers that only count working hours
  • Schedule follow-up tasks within business hours

When NOT to Use This

  • For simple date math that doesn't need business hours awareness, use Flow's built-in date formulas
  • If you need to subtract business hours (this action only adds time)
  • For complex scheduling with multiple business hour sets per record — you'd need custom logic

User Guide

Getting Started

  1. Deploy the addBusinessHours Apex class to your Salesforce org
  2. Add the "Add Business Hours" action to your Flow
  3. Pass in the start DateTime, Business Hours ID, and interval in milliseconds
  4. The action returns the calculated next business DateTime

Inputs & Outputs

Input3 attributes
startDateRequired
DateTime

The starting date and time for the calculation

businessHoursIdRequired
Text

The ID of the Business Hours record to use (from Setup > Business Hours)

intervalMillisecondsRequired
Number

The amount of time to add, in milliseconds (e.g., 3600000 for 1 hour)

Output1 attribute
nextBusinessDate
DateTime

The calculated future DateTime after adding the interval through business hours only

Common Time Conversions

DurationMilliseconds
1 hour3,600,000
4 hours14,400,000
8 hours (1 business day)28,800,000
24 hours (3 business days)86,400,000

Troubleshooting

Result is in wrong timezone: The action converts the result to the running user's local timezone. If the result seems off, check the user's timezone setting in Salesforce.

Business Hours ID not found: Make sure you're passing a valid Business Hours record ID. You can find this in Setup > Business Hours. Use a Get Records element to query the BusinessHours object.

Interval seems wrong: Remember the interval is in milliseconds, not hours or minutes. Multiply hours by 3,600,000.

Code

Source code is available on GitHub. The component consists of two Apex classes in a standard SFDX project structure:

  • addBusinessHours.cls — The invocable action with Request/Response inner classes
  • addBusinessHoursTest.cls — Test class with coverage for the default business hours
  • Metadata XML files configured for API version 66.0

Deploy to your org using SFDX:

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

Release History

See the release timeline above for version history.

Search

Search components, articles, and tags