I have a custom object invoice in which i have three custom fields Work_Start_Time__c
, Estimate_Time_To_Complete__c
, and Target_Date_Time__c
. We have 9 hours working hours in a day from 9 am to 7 pm.
If a user enters today's date in Work_Start_Time__c
and time is 3 pm and in Estimate_Time_To_Complete__c
the user puts 8 hours, then in Target_Date_Time__c
the value should be 12:00 Pm of next days not the 10:00 pm of the same day in my case its shows 10:00Pm of same days in Target_Date_Time__c
custom field.
Here is my trigger
trigger DailyWorkTrackersTrigger on Invoice__c (before insert, before update) {
for(Invoice__c workObj: Trigger.new) {
workObj.Target_Date_Time__c = workObj.Work_Start_Time__c.addMinutes(Integer.valueOf(String.valueOf(workObj.Estimate_Time_To_Complete_Hrs__c * 1000 * 60 * 60)));
}
}