You need to sign in to do that
Don't have an account?
KRavi
Merge fields not working on Visualforce Email template
I have requirement to display cross object fields (related through LOOKUP)
i created a VFpage, VF Component and controller
public class WasteProfileApprovalTemplt
{
public List<Approved_Destination__c> lstDest { get;set;}
public Id WPId {get;set;}
public WasteProfileApprovalTemplt(){
lstDest= [SELECT Name,Facility__c,Facility__r.name,Facility_Code__c,Primary_Process_Code__c,Primary_Process_Code__r.name,CreatedDate,CreatedById
FROM Approved_Destination__c WHERE Waste_Profile__c =: WPId];
}
public List<Approved_Destination__c> lstGetAppDests(){
system.debug('lstDest:' + lstDest);
return lstDest;
}
/* public String lstDest { get; set; }
public Id WPId {get;set;}
public List<Approved_Destination__c> lstGetAppDests()
{
List<Approved_Destination__c> lstDest;
lstDest= [SELECT Name,Facility__c,Facility__r.name,Facility_Code__c,Primary_Process_Code__c,Primary_Process_Code__r.name,CreatedDate,CreatedById
FROM Approved_Destination__c WHERE Waste_Profile__c =: WPId];
return lstDest;
} */
}
--VF COmponent
<apex:component controller="WasteProfileApprovalTemplt" access="global">
<apex:attribute name="WProfId" type="Id" description="Id of the WasteProfile" assignTo="{!WPId}"/>
<table border = "2" cellspacing = "5">
<tr>
<td>Approved Waste Destination ID</td>
<td>Facility Common Name</td>
<td>Facility Code</td>
<td>Primary Process Code</td>
<td>Created Date</td>
</tr>
<apex:repeat value="{!lstDest}" var="wp">
<tr>
<td>{!wp.Name}</td>
<td>{!wp.Facility__r.name}</td>
<td>{!wp.Facility_Code__c}</td>
<td>{!wp.Primary_Process_Code__r.Name}</td>
<td>{!wp.CreatedDate}</td>
</tr>
</apex:repeat>
</table> </apex:component>
--VF Page
<messaging:emailTemplate subject="Waste Profile Approval Notification" recipientType="User" relatedToType="Profile__c">
<messaging:htmlEmailBody >
<html>
<body>
<p>*** Stericycle Waste Profile Approval Notification***</p>
<p>The following Stericycle Waste Profile has been conditionally approved pending generator signature and return of</p>
<p>the attached profile document:</p>
<p>Profile #: {!relatedTo.PreviewID__c}</p>
<p>Waste Description: {!relatedTo.WasteDescription__c}</p>
<p>Account: {!relatedTo.Account__c}</p>
<p>Queue: {!relatedTo.Queue__c}</p>
<p>Approval Submission Date: {!relatedTo.Approval_Submission_Date__c}</p>
<p>Submission Priority: {!relatedTo.Submission_Priority__c}</p>
<c:WasteProfileApprovalTemplt WProfId="{!relatedTo.Id}" /><br/><br/>
<p/>
<p>Acceptance Statement: In accordance with 40 CFR 264.12(b), the following Stericycle, Inc. facilities have the
appropriate federal and state permits for, and will accept the waste the generator is shipping as described in this
profile. Additional facilities may be evaluated and added on an as needed basis. </p>
<p/>
<p> https://cs24.salesforce.com/{!relatedTo.Id}</p>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
In the email, I couldnt get the values from the Object in Controller.
DId i miss something.
appreciate your help in advance.
i created a VFpage, VF Component and controller
public class WasteProfileApprovalTemplt
{
public List<Approved_Destination__c> lstDest { get;set;}
public Id WPId {get;set;}
public WasteProfileApprovalTemplt(){
lstDest= [SELECT Name,Facility__c,Facility__r.name,Facility_Code__c,Primary_Process_Code__c,Primary_Process_Code__r.name,CreatedDate,CreatedById
FROM Approved_Destination__c WHERE Waste_Profile__c =: WPId];
}
public List<Approved_Destination__c> lstGetAppDests(){
system.debug('lstDest:' + lstDest);
return lstDest;
}
/* public String lstDest { get; set; }
public Id WPId {get;set;}
public List<Approved_Destination__c> lstGetAppDests()
{
List<Approved_Destination__c> lstDest;
lstDest= [SELECT Name,Facility__c,Facility__r.name,Facility_Code__c,Primary_Process_Code__c,Primary_Process_Code__r.name,CreatedDate,CreatedById
FROM Approved_Destination__c WHERE Waste_Profile__c =: WPId];
return lstDest;
} */
}
--VF COmponent
<apex:component controller="WasteProfileApprovalTemplt" access="global">
<apex:attribute name="WProfId" type="Id" description="Id of the WasteProfile" assignTo="{!WPId}"/>
<table border = "2" cellspacing = "5">
<tr>
<td>Approved Waste Destination ID</td>
<td>Facility Common Name</td>
<td>Facility Code</td>
<td>Primary Process Code</td>
<td>Created Date</td>
</tr>
<apex:repeat value="{!lstDest}" var="wp">
<tr>
<td>{!wp.Name}</td>
<td>{!wp.Facility__r.name}</td>
<td>{!wp.Facility_Code__c}</td>
<td>{!wp.Primary_Process_Code__r.Name}</td>
<td>{!wp.CreatedDate}</td>
</tr>
</apex:repeat>
</table> </apex:component>
--VF Page
<messaging:emailTemplate subject="Waste Profile Approval Notification" recipientType="User" relatedToType="Profile__c">
<messaging:htmlEmailBody >
<html>
<body>
<p>*** Stericycle Waste Profile Approval Notification***</p>
<p>The following Stericycle Waste Profile has been conditionally approved pending generator signature and return of</p>
<p>the attached profile document:</p>
<p>Profile #: {!relatedTo.PreviewID__c}</p>
<p>Waste Description: {!relatedTo.WasteDescription__c}</p>
<p>Account: {!relatedTo.Account__c}</p>
<p>Queue: {!relatedTo.Queue__c}</p>
<p>Approval Submission Date: {!relatedTo.Approval_Submission_Date__c}</p>
<p>Submission Priority: {!relatedTo.Submission_Priority__c}</p>
<c:WasteProfileApprovalTemplt WProfId="{!relatedTo.Id}" /><br/><br/>
<p/>
<p>Acceptance Statement: In accordance with 40 CFR 264.12(b), the following Stericycle, Inc. facilities have the
appropriate federal and state permits for, and will accept the waste the generator is shipping as described in this
profile. Additional facilities may be evaluated and added on an as needed basis. </p>
<p/>
<p> https://cs24.salesforce.com/{!relatedTo.Id}</p>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
In the email, I couldnt get the values from the Object in Controller.
DId i miss something.
appreciate your help in advance.