You need to sign in to do that
Don't have an account?
Tej
visual force email Template with approval comments
when the record gets aproved, we need to send an email with approval comments.
i created a visualforce email template, visualforce component and controller.
when i test it from email template from the button - "Send Test And Verify Merge Fields" everything working fine, but in real transaction the comments are coming empty.
attached is the code.
Any body dealt with this kind of req? Please help
Component:
<apex:component controller="JCApprovedEmailTemplate" access="global" > <apex:attribute name="jcId" assignTo="{!jcId}" type="String" description="ID of JobCode"/> <apex:dataTable value="{!approvalSteps}" var="step"> <apex:column value="{!step.Comments}"/> </apex:dataTable> </apex:component>
Controller:
public class JCApprovedEmailTemplate { public String jcId { get; set; } public list<ProcessInstanceHistory> getApprovalSteps() { system.debug('------------------------------jcID--------------'+jcId); if (jcId != null) { Job_Code__c jc = [Select Id, (Select TargetObjectId, SystemModstamp, StepStatus, RemindersSent, ProcessInstanceId, OriginalActorId, IsPending, IsDeleted, Id, CreatedDate, CreatedById, Comments, ActorId From ProcessSteps order by SystemModstamp desc limit 1) from Job_Code__c where Id = :jcId ]; system.debug('------------------------------jcID--------------'+jc); system.debug('------------------------------jc.ProcessSteps--------------'+jc.ProcessSteps); return jc.ProcessSteps; } return new List<ProcessInstanceHistory> (); } }
Visual Force Email Template:
<messaging:emailTemplate subject="Notice of Approved Job Code Request" recipientType="User" relatedToType="Job_Code__c"> <messaging:HtmlEmailBody > <html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/> <meta name="Template" content="Response"/> <p> A request for a Job code update {!relatedTo.Job_Title__c} was approved<br/></p> </head> <body> <p> <b>Approver:</b> {!relatedTo.Product_Area_Approver__r.Name}<br/> </p> <p> <b>Comments: </b> <c:JCApprovedEmailTemplate jcId="{!relatedTo.Id}"/></p> </body> </html> </messaging:HtmlEmailBody> </messaging:emailTemplate>
try to add the list as variable in your class.