function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tom sanchestom sanches 

Pass emailTemplate.Body to lightning-input-rich-text

I tried to use the EmailTemplate object to get my template by id, but I get the error "Illegal assignment from List <EmailTemplate> to List <EmailTemplate>". Maybe there are other ways?

List<EmailTemplate> emailTemplate = [Select Subject, Body FROM EmailTemplate where  Id='TemplateId'];

Thank you in advance!
Best Answer chosen by tom sanches
tom sanchestom sanches
Okay, In my organization somewhere I have created a class named "EmailTemplate". That is why the compiler is not able to understand that it is standard Object EmailTemplate or the class created in my org. Now I renamed my class to some other name now it's working perfectly.

All Answers

Suraj Tripathi 47Suraj Tripathi 47
Hi Екатерина Дзик,

As I can see your given query is absolutely perfect considering that TemplateId will be replaced by the Id of the email template. You can check the below screenshots for the reference that is showing the query is working properly.
Query : 
Query
Result : 
Result

You must check the following points for your problem:
  • Template Id is being replaced by a proper Email template Id.
  • Error line number by using try-catch.
  • You can use EmailTemplate object in place List of EmailTemplate.
Please mark it as the best answer if it helped you.
Thanks.
mukesh guptamukesh gupta
Hi ,

Your code is almost correct , please update with below code
 
String tempId = '00X28000001lwHQ';// add your template Id here
List<EmailTemplate> listEmailTemplate = [Select Subject, Body FROM EmailTemplate where  Id =: tempId];

for(EmailTemplate temp : listEmailTemplate){
    System.debug('temp-->> '+temp.Subject);
    
}


if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

 
tom sanchestom sanches
Okay, In my organization somewhere I have created a class named "EmailTemplate". That is why the compiler is not able to understand that it is standard Object EmailTemplate or the class created in my org. Now I renamed my class to some other name now it's working perfectly.
This was selected as the best answer