Saturday, 28 January 2023

Holiday Consideration in salesforce

 

Recently, I came across one requirement, where we need to consider holiday.

Suppose, we have one custom object, which has SubmittedDate field, DueDate field.

We have to complete all cases before DueDate, but suppose, if there is any company holidays, we get less time to complete Cases.

Sol:

First we have create Business Hours. To create Business hours, you can search in quick find box “business hours”. On Satuday and Sunday, we don’t have working hours. So , we have metioned “no hours”.



Then we have to create Holidays and associate with business hours.




Suppose, we are submitting the case on 27th January 2023, the due date should be 03rd February 2023, without considering Holidays. It should be 5 business days mainly, excluding holidays and weekends.

With Holiday consideration, the duedate will be 06th February. As, 30th January( Test1), i have considered holiday.




addGmt(businessHoursId, startDate, intervalMilliseconds) :

Adds an interval of milliseconds from a start Datetime traversing business hours only. Returns the result Datetime in GMT.

No comments:

Post a Comment

Duplicate id in list

  Error 'System.ListException: Duplicate id in list' in Apex : list  can hold  duplicate values, but if you try to add duplicate  sO...