You need to sign in to do that
Don't have an account?

VF Email Template
Hi All
I am trying to create a visual force Email template. I wanted to add custom object fields in the email template. I created a apex controller, component and i called the component in to VF page template but still unable to find out the custom fields in the VF template which i added in the component. Here is the thing i did
Controller
public class CAFApprovalHistoryController {
public CAF__c cf;
public String cafId {get;set;}
public List<ProcessInstanceHistory> getApprovalSteps() {
if (cafId != null) {
CAF__c cafs = [Select Id, Name, CAPEX_Total__c, Off_Net_Circuit_Expense_Total__c, CAF_IRR__c, of_Revisions__c, Sales_Rep__c, Sales_Manager__c, Account__c, CAF_Title1_del__c, CAF_1__c, Products_Requested__c, Bandwidth__c, Notes_of_Consideration__c, CAF_Link__c, (Select TargetObjectId, SystemModstamp, StepStatus, RemindersSent, ProcessInstanceId, OriginalActorId, IsPending, IsDeleted, Id, CreatedDate, CreatedById, Comments, ActorId From ProcessSteps order by SystemModstamp desc) from CAF__c where Id = :cafId];
return cafs.ProcessSteps;
}
return new List<ProcessInstanceHistory> ();
}
public CAF__c getcaf(){
return cf;
}
}
Component. Blue are the custom object fields which i added in the component. But, i am unable to see those in the VF email template
<apex:component controller="CAFApprovalHistoryController" access="global">
<apex:attribute name="cafId" assignTo="{!cafId}" type="String" description="Id of the CAF"/>
<apex:dataTable value="{!approvalSteps}" var="step">
<apex:column value="{!step.SystemModstamp}" headerValue="Date"/>
<apex:column value="{!step.StepStatus}" headerValue="Status"/>
<apex:column value="{!step.OriginalActorId}" headerValue="Assigned To"/>
<apex:column value="{!step.ActorID}" headerValue="Actual Approver"/>
<apex:column value="{!step.Comments}" headerValue="Comments"/>
<apex:outputLabel value="CAF" for="CAF__c.CAFId">
<apex:pageBlockSection >
<apex:outputField id="CAPEX" value="{!CAF.CAPEX_Total__c}"/>
<apex:outputField id="OffNetCircuitExpense" value="{!CAF.Off_Net_Circuit_Expense_Total__c}"/>
<apex:outputField id="SalesManager" value="{!CAF.Sales_Manager__c}"/>
</apex:pageBlockSection>
</apex:outputLabel>
</apex:dataTable>
</apex:component>
And i called the above component in the VF template mentioned in Red in the below code. Here is my VF Template.
<messaging:emailTemplate subject="Your CAF has been Rejected" recipientType="User" relatedToType="CAF__c">
<messaging:HtmlEmailBody >
Rejected!
<br/>
Your CAF has been rejected.
<br/>
Below are the approval rejection comments
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<meta name="Template" content="Response"/>
</head>
<body>
<br/>
<b>Capital Planning will follow up on the rejection of this CAF. Please do not reply to this e-mail.</b>
<br/>
<b>CAF Details</b>
<br/>
<p><b>Approval History</b>
<c:CAF_Approval_History_Component cafId="{!relatedTo.Id}"/>
</p>
</body>
</html>
</messaging:HtmlEmailBody>
</messaging:emailTemplate>
You may want to check the field level security for those fields.
Hope that helps.
Afzal