You need to sign in to do that
Don't have an account?
sfadm sfadm
Need to calculate the out of office hours in apex
I need to calculate the out of office hours in apex.
The hours are:
6 pm – 9 am Mon – Fri
and
6 pm on Fri till 9 am on Mon
I've already configured the Business Hours:
Monday09:00to18:00
Tuesday09:00to18:00
Wednesday09:00to18:00
Thursday09:00to18:00
Friday09:00to18:00
Saturday24 Hours
Sunday24 Hours
and activate it in Salesforce.
Please advise how it can be achieved in apex?
For any Day first thing you can check is If the date is a Business Day of not using below method businessHoursId will be the calendar Id
targetDate will be the date for which u are looking to calculate business hours
Example Using the same developer refrence,
If it returns true, u can take the tagretDate time and subtract it from 18:00 number of pending hours will give you business hours remaining for that day.
Does that help?
Thanks
All Answers
Let me know if any further help you need.
Thanks,
JS
I need to get the working hours in the same bussines day in the following code:
In the while loop of the ELSE clause I'm subtracting the workingHours from diff but I'm stuck in the IF clause. In the IF clause I need to get the working hours in the same bussines day.
I need some clue how to achieve that.
For any Day first thing you can check is If the date is a Business Day of not using below method businessHoursId will be the calendar Id
targetDate will be the date for which u are looking to calculate business hours
Example Using the same developer refrence,
If it returns true, u can take the tagretDate time and subtract it from 18:00 number of pending hours will give you business hours remaining for that day.
Does that help?
Thanks