+ Start a Discussion
Stefano AmentaStefano Amenta 

Default email template not showing up in Email Action

Hi,

I created an email action in the case feed and an apex class to show the default email template, but it doesn't work yet, the template doesn't load.

I have activated the default template checkbox in Support Settings as well, and the template is available for use.

Does anyone know why it doesn't work?

Thanks.

User-added image

User-added image
This is the class:
 
global class E1DefaultTemplateEmail implements Support.EmailTemplateSelector {

    global E1DefaultTemplateEmail() {    }

    global ID getDefaultEmailTemplateId(ID caseId) {

        Case c = [SELECT Subject, Description FROM Case WHERE Id=:caseId];

        EmailTemplate et;

        if (c.subject != null) {
            et = [SELECT id FROM EmailTemplate WHERE DeveloperName = 'E1HC_Send_e_mail_with_case_description'];
        }         

        return et.id;
    }
}

 
Best Answer chosen by Stefano Amenta
Stefano AmentaStefano Amenta
I was using the incorrect action name and action type in these two lines of code.
defaults.get(j).getActionName().equals('Case.E_Mail_to_User_IT') && 
               defaults.get(j).getActionType().equals('SendEmail'))
By adding a debug line such as the one below, I found out the correct values to use. Now the email template is loading.
 
System.debug(LoggingLevel.INFO, '*** : ' + defaults[0]);


 

All Answers

Amit Jadhav 13Amit Jadhav 13
Hii Stefano Amenta Are You Created Email Alert for That Email Template 
Please Check Once Again
Thank You!

Regard's
Amit Jadhav 
Salesforce Developer
Stefano AmentaStefano Amenta
Hi Amit Jadhav 13

I don't think I need an email alert in this scenario.

I only need to show a default email template in the email body when our agent is about to reply to a case from the feed section.
Stefano AmentaStefano Amenta
I was using the incorrect action name and action type in these two lines of code.
defaults.get(j).getActionName().equals('Case.E_Mail_to_User_IT') && 
               defaults.get(j).getActionType().equals('SendEmail'))
By adding a debug line such as the one below, I found out the correct values to use. Now the email template is loading.
 
System.debug(LoggingLevel.INFO, '*** : ' + defaults[0]);


 
This was selected as the best answer