Holiday Notifications
Holiday Notifications: Automate Delay Alerts for Case Creation in Salesforce
Why Automate Holiday Notifications?
During holidays, our support team might have fewer staff or take longer to respond. An automated notification system can help by letting customers know in advance about possible delays. This helps manage their expectations, makes their experience better, and reduces the chance of them getting frustrated.
Setting Up Your Holiday Auto-Responder in Salesforce
Here are the steps to identify if a case is created on a holiday and notify the customer about a possible delay:
– Create a Flow
– Apex class
– Email Template
– Email Alert
1. Create an Apex Class for Accessing Holiday Data
To start, we need an Apex class that interacts with the standard `Holiday` feature. This class will allow us to check if a given date falls within a holiday period.
Apex Class Example:
public class HolidayHandler {
// Method to get all holidays
public static List getHolidays() {
List holidays = [SELECT Id, Name, StartDate, EndDate, Description FROM
Holiday];
return holidays;
}
// Method to get holidays within a specific date range
public static List getHolidaysWithinRange(Date startDate, Date endDate) {
List holidays = [SELECT Id, Name, StartDate, EndDate, Description
FROM Holiday
WHERE StartDate >= :startDate AND EndDate <= :endDate];
return holidays;
}
// Method to check if a given date is a holiday
public static Boolean isDateHoliday(Date dateToCheck) {
List holidays = [SELECT Id FROM Holiday WHERE StartDate <= :dateToCheck
AND EndDate >= :dateToCheck];
return !holidays.isEmpty();
}
}
2. Create an Email Template
1.Navigate to : Setup > Email Templates.
2. Create a New Template : Name it “Holiday Auto-Responder Template”.
3. Draft the Conten : Write an email informing requesters about potential delays due to holidays. Include placeholders for personalization.
3. Set Up a Flow for Holiday Auto-Responder
- Navigate to : Setup > Flows.
2. Create a New Flow : Select Record-Triggered Flow.
3. Choose Object : Select Case (or your custom ticket object).
Flow Configuration:
Trigger :
– Set the flow to trigger when a case is created or updated.
2. Add Decision Element :
– Use a “Decision” element to determine if the case date falls within any holiday period.
– Call the Apex method “HolidayHandler.isDateHoliday({!Case.CreatedDate})”.
3. Add Apex Action :
– Add an “Apex Action” to call “HolidayHandler.isDateHoliday”.
– Pass the case creation date or relevant date to this action.
4. Create Email Alert Action :
– Add an “Action” element for “Email Alert”.
– Select the “Holiday Auto-Responder Template”.
– Set the recipient to “Case.ContactEmail” or the relevant field.
4. Test and Validate
- Save and Activate : Ensure the flow is active.
2. Create Test Cases : Simulate cases during holiday periods to verify the auto-responder.
3. Verify Email Delivery: Ensure that emails are sent with the correct holiday notification message.
Conclusion
Automating holiday delay notifications in Salesforce helps maintain transparency with your customers and ensures they are informed about potential delays during the holiday season.