You need to sign in to do that
Don't have an account?
aam1r
Get Business Hours Start of Day
Hi, i'm trying to record the start of day date/time value for a given Business Hour as part of an Apex trigger but not sure of the way to do this. Can someone help me try and achieve this please? The basic logc is to check what day it is today and then record the Start of Day date/time in to a field (Start_of_Day__c) for that same day defined for the Business Hour.
Thanks
Thanks
To achieve this functionality you have to set up business hours in your org. After set up business hours user following code in your trigger.
Hope it helps you. Let me know if it helps you.
Thanks,
Anjith Kumar.
All Answers
In order to get they day in your trigger use follow code snippet.
I hope this will work for you.
Thanks
To achieve this functionality you have to set up business hours in your org. After set up business hours user following code in your trigger.
Hope it helps you. Let me know if it helps you.
Thanks,
Anjith Kumar.
Naval - firstly, love the last question.. or rather the tiiming of it! Now, your solution gave me an error as i'm tryig to assign a time value to a date/time field. I did not try to correct that before attemting to work at the remainig logic.
Anjith - thanks for your suggestion. It worked as is. and yes Business Hours were already defined. it was teh xtraction of the date and time i was struggling with.
Thanks again guys.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_businesshours.htm#apex_System_BusinessHours_diff
and its the second last line giving me 'Method does not exist or incorrect signature: [Datetime].addHours(Long)'
Note: i had to change second line from 'BusinessHours.id' to 'bh.id' as this also was throwing an error. not sure how it worked for you though.
let me know if it works.
thanks,
Anjith