+ Start a Discussion
EdCodeEdCode 

Schedule Email alerts based on Business Hours/Holidays

Hello Stars,

I have the following Requirement from The Business:

When receiving an Email-2-Case (which inserts a Case in SFDC), automatically:

a) Evaluate if Region__c = xyz, is so, ...
b) Send, immediately, an automated response to the sender;
c) If Case.Type = 'Enquiry' ==> send an email (to sender) 2 Business Days after Case.CreatedDate;
d) If Case.Type = 'Complaint' ==>
  d.1) send an email (to sender) 5 Business Days after Case.CreatedDate;
  d.2) send another email (to sender) 10 Business Days after Case.CreatedDate;

I was going to levarage the standard Process Builder Scheduled Actions but realised that this functionality does not factor in Business Hours!

I think that the standard Time Based Workflow functionality also ignores Business Hours.

QUESTION: Which of the following solution designs should I build?

1) Create a custom Date field on the Case object where, somehow, I would have to insert the Next-Date-Time when the next email should be sent (excluding weekends and holidays from the counted days);

2) Create an apex class in charge of:
   2.1) querying the relevant Busines Hours (1 record) and...
   2.2) calculating the Next-Date-Time when the next email should be sent (only factoring-in Business Hours) AND...
   2.3) sending a predefined email template.

(The email template to be sent is stored in the standard object EmailTemplate)

Any other approach that I may be missing?

Have you already built any of the above 2 solutions? (please share!)

Thank you.
EdCodeEdCode
An additional alternative option, I think, could also be:

Invoking an Apex method from a Process Builder.

(I am not sure yet if the Process Builder will be able to schedule an Email Alert based on infomation (Next-Date-Time to send it) provided by apex (?)
PriyaPriya (Salesforce Developers) 

Hi EdCode,

You can proceed with first option where you can set the business hours for your org by excluding weekends and holidays. For referrence, visit the below link :- 

https://salesforcescool.blogspot.com/2018/11/calculate-business-days-in-salesforce.html#:~:text=This%20object%20easily%20accessible%20under,%22New%20Business%20Hours%22%20button

Please mark it as best answer if it met your requirement.

Thanks