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
benito camelabenito camela 

Ideas Title not displayed in template email

Hi, I have an email template (type:Visualforce) that is sent each time someone comment an Idea.

 

trigger myIdeas on Idea (after update) {
    
    if(Trigger.isAfter){
        for (Idea i : Trigger.new) {
			if(i.LastCommentDate > i.LastModifiedDate){
				Id emailId = [SELECT Id FROM EmailTemplate WHERE DeveloperName='New_Ideas_comment'].id;
				String[] toAddresses = new String[] {'test@test.com'}; 

				Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
				mail.setToAddresses(toAddresses);
				mail.setSenderDisplayName('test test');
				mail.setTemplateId(emailId);
				mail.setTargetObjectId(i.CreatedById);
				mail.saveAsActivity = false;
				Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
			}
        }
    }
    
}

 ... and my template:

<messaging:emailTemplate subject="The Idea {!relatedTo.title} has a new comment" recipientType="User" relatedToType="Idea">
<messaging:plainTextEmailBody >

Dear {!recipient.FirstName} {!recipient.LastName}

{!relatedTo.Title}

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 {!relatedTo.Title} is blank. Do you know what's the problem ?

 

 

The crazy thing is that when I use a template of type TEXT, it works !!!

 

e.g.: Subject: New Comment ({!Idea.NumComments}) on Idea: {!Idea.Title}

 

Thanks

benito camelabenito camela

Sorry, but with text email templated I have the same problem, the Ideas fields are not merged. Is this happening because I'm adding a comment and not updating the Idea itself ?