Questions tagged [businesshours]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
31 views

Trigger Run Outside of Business Hours

I have my simple trigger working now where once a threshold is met for cases created within 60 minutes it updates the "SendAlert" field so my workflow can start going to work. The next steps I am ...
0
votes
1answer
23 views

how do i give permission of updating business hours to a normal user other than system administrator?

Is there a way we can give a normal user with the previlage of updating business hours and holidays in salesforce? Any supporting URL would be really helpful. Thanks in advance.
0
votes
1answer
17 views

Why is my entitlement not stopped during support holidays?

I have an entitlement process with a single milestone in it. I've created a support holiday and linked it to the business hours record I have set up on the milestone and on the entitlement process. ...
0
votes
1answer
52 views

Business Hours calculation is incorrect/ not consistent for certain dates

My use case is to calculate the deadline to respond on the Case. Rule is to add 10 business days from the complaint received date. Defined the business hours: Logic 1 Date initialDate = ...
3
votes
1answer
119 views

Businesshours.nextStartDate is returning value which is on a holiday

In our org, I have set-up business hours as 08:00-16:00 and timezone is GMT +2. Saturdays and Sundays are blank which means they are holidays. I then went in and set-up Holidays and have put the 24th,...
6
votes
2answers
59 views

Does SFDX add any way of automating the setup of business hours?

It wasn't (and I assume still isn't?) possible to programmatically set up business hours via Apex code in unit tests: Set Business Hours in Apex Test Code Creating Holidays and Business Hours in Test ...
0
votes
1answer
165 views

Escalate case using business hours

We are using process builder to escalate a case and send email notifications to specific queues. The escalation works using scheduled actions...i.e. after 1 hour send email, after 2 send another email ...
1
vote
1answer
198 views

Business Hours difference calculation during BST

Hello I need help understanding how business hours difference is calculated with the Apex class. The documentation is rather poor and doesn't explain the input parameters assumptions. I found one post ...
1
vote
1answer
80 views

Update action in x business hours

I have a requirement where I need to send email in 8 business hours. It should respect holidays and weekends. Example: Office Hours 8 AM to 5 PM If case is created at 4 PM Friday then email must be ...
0
votes
0answers
176 views

BusinessHours.isWithin() Not Working As Expecting

I am using the BusinessHours class and am just running some basic tests: BusinessHours bh = [SELECT Id, ThursdayStartTime FROM BusinessHours WHERE IsDefault = true]; if (BusinessHours.isWithin(bh.Id, ...
3
votes
2answers
71 views

Does BusinessHours diff() method work with standard CreatedDate field in Before Update Trigger?

I will start off with a code snippet: trigger CaseTrigger on Case (before insert, before update) { BusinessHours defaultHours = [select Id from BusinessHours where IsDefault=true]; ...
1
vote
1answer
45 views

BusinessHours and scheduled dates

I am trying to create a payment schedule off of a input field DATE. If the date falls on a Weekend or on a Holiday then I want to move the payment date to the next open business day. I was using the ...
1
vote
1answer
33 views

Need to add only business days

In Opportunity i created a formula date field. in which i want only it take business days means like:TODAY() + ( ( ( 0.7 * ( Total_Payback_Amount__c ) ) - Total_Collected_to_Date__c ) / ...
1
vote
0answers
240 views

Create Test data within business hour and outside of business hours?

I have below code and for that I am trying to write the test classes. As per code look like Case should be created within Business hours and other condition says that, case should be created outside ...
0
votes
1answer
277 views

Add 5 Business days calculates wrong Target Date value in salesforce?

Business hours is set to 7 AM to 7 PM Mon to Fri, Time Zone (GMT-05:00) Eastern Standard Time (America/New_York). I need to simply add 5 working days from Current Date in order to calculate the ...
1
vote
0answers
116 views

BusinessHours API not returning correct isWithin() value

I'm trying to use APEX BusinessHours class to check whether a certain Date is a Business Day or Not. Here is my Business Hour in my Organization: Based on this, if I provide following date input, it ...
1
vote
1answer
65 views

Hitting CPU Limit using BusinessHours

I am working on a method that adds business days using the BusinessHours class. Here is the method I'm working on: public static Date addBusinessDays(Date d, integer dayDifference, Id ...
1
vote
1answer
200 views

Find the next several days time according to business hours

I need to build a formula based on the start time, order type and business hours. start time and due time are datetime. The difficult part about this is I need to calculate this around the business ...
2
votes
1answer
60 views

Apex Business Hours calculation glitch

I have a salesforce org with business hours set up from 8AM - 6PM (10 hours). Corporate holidays are on 25,26th Dec and 1st Jan. I'm using the standard apex method BusinessHours.add() to calculate ...
0
votes
1answer
438 views

Business Hours and Time Zones (EDT vs EST?)

I have trigger code that is calculating the span between two Date/Time fields - respecting Business Hours - easy. Business Hours end daily at 5pm - and the Time Zone is set to EST (however we're ...
0
votes
2answers
1k views

Calculate No of working days difference between two dates?

This could be the very simple use case, but I am straggling to make this working. How we can find out the business working days difference between two dates ? I know 8/26/2017 is Saturday, next days ...
-1
votes
2answers
446 views

Method does not exist or incorrect signature: [BusinessHours].diff(Id, Time, Time) [duplicate]

I am working on the BusinessHours and I am getting the below error. I just want to calculate the no. of hours difference between MondayStartTime and MondayEndTime Method does not exist or incorrect ...
-1
votes
1answer
37 views

Incompatible element type Time for collection of Datetime for BusinessHours

I working to calculate the business hours from the Business day: List<BusinessHours> bhList = [SELECT FridayEndTime,FridayStartTime,Id,IsActive,IsDefault,LastModifiedById, ...
0
votes
4answers
8k views

How can I get my correct current local time?

I need to get the current time but to be in type DateTime. I use: DateTime now = System.now(); but it returns wrong time. I execute the code in 2017-08-04 00:38:46 AM but it returns 00:38:46:023 ...
0
votes
1answer
281 views

DateTime set to an hour earlier

I have an object of type Time startWorkingTime and object of type DateTime nextBusinessDay. I want to create new object of type DateTime based on startWorkingTime and nextBusinessDay. Here is my code:...
1
vote
2answers
548 views

BusinessHours class returns incorrect time difference

I am using business hours class to get the hours, minutes difference between when a lead is assigned to a user and when it is acted upon. The business hours are 7 AM to 4 PM from Monday to Friday, ...
0
votes
2answers
70 views

Calculate hours based on Task priority

I need help to achieve the following: When a Task priority is changed by a particular user, I must set a fixed amount of REAL (non-working) hours in a custom field in the same Task. The purpose is to ...
0
votes
1answer
59 views

How do I get time spent on a Task, excluding Holiday and Non-working hours?

How do I get time spend on a Task, excluding Holiday and Non-working hours? I'd like to get the total time spent on a Task, excluding holidays and non working hours. Is there a feasible way and how ...
1
vote
0answers
371 views

Minutes between 2 Datetime fields excluding weekends

I pulled a formula from the Success boards to calculate the total minutes between 2 date/time fields, but exclude weekend hours. However, it is spitting out a value of "0" when the value should ...
0
votes
2answers
40 views

Counting Business days

I am looking to count business days from when a status is picked in a pick list on a case. I have the field awaiting customer input data adding today's date when the status is picked. This is working ...
1
vote
1answer
976 views

Calculation of business hours between two date time fields

Id businessHoursId = [select Id from BusinessHours where isdefault = true ].id; DateTime dateTime1 = Datetime.valueOf('2015-07-10 12:00:00'); DateTime dateTime2 = Datetime.valueOf('2015-07-13 12:00:00'...
1
vote
2answers
257 views

How to trigger email after last modified but within business hours

I have Business Hours enabled in my org. I have created a process builder which triggers an email 24 hours after last modified date of a particular case. However I am not being able to understand ...
1
vote
1answer
335 views

not being able to query BusinessHours in Case object

I have set up Business Hours in my org. A field called BusinessHours appears in the Case Standard field List. However as soon as I try to query using workbench, it throws an error select ...
2
votes
1answer
514 views

How are Business Hours added to a case?

I am just learning SF and I am noticing that there seems to be no rhyme or reason with what business hours get set on a case. I opened 8 cases. Two cases Email-to-Case and two through our customer ...
0
votes
2answers
271 views

Test Class for using Business hours to create a task on lead

I am work on test class for the following code. The code uses the business hours from Salesforce and applies a task to anything lead that comes in after business hours. The issue is I cant get the ...
0
votes
1answer
578 views

How to calculate Hours and minutes using Business Hours?

I have used this to calculate hours , but minutes part is not getting covered. long businessMillisecondsDiff = BusinessHours.diff(bh.Id,cs.CreatedDate,system.now()); decimal businessHoursDiff = ...
0
votes
3answers
2k views

Add days to created date excluding weekend and holidays

I have written the following code . But it's not giving result nor any error. My requirement is to add 3 days to CreatedDate, excluding weekend and holidays. Datetime createdDate = system.now(); ...
0
votes
1answer
30 views

Method does not exist in business hour?

BusinessHours oBh = [SELECT Name,Id FROM BusinessHours where name='FR']; datetime leaCreatedDate =DateTime.now(); Long slaSeconds =864000000; system.debug('oBh<<'+oBh.id); system.debug('oBh&...
3
votes
1answer
178 views

Send email alert exactly after 4 business hours from Task Created Date

We have a requirement to send an email alert to users after 4 business hours from Task Creation Date ie., Our Business hours are from 7am to 5pm (Monday to Friday) and if Task is created at 4pm on ...
1
vote
1answer
53 views

How to utilize buisnessHours class instead of time class

I have a main if statement in my class that utilizes CreatedDate.hour() to execute certain code between 6pm and 8.59am and the ELSE is 9am to 5.59pm which would be within business hours if I could get ...
0
votes
1answer
1k views

formula field to exclude weekends and public holidays [duplicate]

Currently i have a formula field on case object, which will return the no. of days the case is not touched. Here, i wanted to exclude the weekend days and the public holiday (which are already created ...
2
votes
1answer
3k views

Calculating business days using BusinessHours class

Our business has a requirement to calculate a due date on a case by using the created date and adding business hours, or business days. When we calculate business days it converts the days to 24 hours ...
0
votes
1answer
589 views

We have business hours that operates 11PM to 8AM but SF have validation Start time must be earlier than end time

we have number sets of business hours of shifting of our agents. Were wondering why Salesforce.com not allowing to set the end time earlier than the start time. We would like to use the standard ...
1
vote
3answers
295 views

BusinessHour NextStartDate Method is returning start time of next business day

I have a question in BusinessHour NextstartDate method. When I am using nextStartDate(businessHoursId, targetDate) method , I am not getting the Start time of next business day. Instead it is ...
2
votes
1answer
469 views

Wrong Business Hours Calculation (Formula)

I have a formula field that calculates business hours (M- F > 09:00 AM to 5:00 PM- 8 hours) between two date time fields. i actually used exactly same formula that sf helps provided. https://...
0
votes
1answer
587 views

Need to find whether my time stamp is between the business hours

I am trying to implement SLA for Lead management. So handling all the SLA functionalities on a trigger and Apex class. I need help in getting the current time and comparing it to the defined ...
2
votes
1answer
476 views

Implement Business Hours for Email Triggers

I have a client requirement where I want to send some notification emails only during weekdays and business hours. I tried to Google this, and got to see that 'Business Hours' functionality must be ...
2
votes
1answer
930 views

BusinessHours - How to simply determine if a given day is a business day

I am simply trying to utilize different BusinessHours and the BusinessHours class to determine if a given date is within x number of business days from another date. The following are true: The hour ...
1
vote
2answers
729 views

How to calculate organisation business hours?

I need to store the organization business hours value in a field .. Is it possible to store that in a formula field ? If not , by any chance can we get the organization business hours through coding ...
2
votes
1answer
351 views

Trouble in using Business hours methods to compare business hours with specific number of hours in apex trigger

I'm trying to compare number of business hours with number of hours (bh<48) I have gone through few methods and tried the below method to get number of hours(difference between startdate and ...