I am using a visualforce email template from Apex Batch class.That visual forc template is using a component for email body generation. Now, I am using custom setting(type list) to get dynamic email body based on country. But I am unable to access the custom settings field value(line1__c, line2__c etc from below code) from either constructor or getter setter.
Please note, when I am using harcoded text instead of custom settings field, the email works absolutely fine.
Below is the code.
Email Template:
<messaging:emailTemplate subject="Pending Letter" recipientType="Contact"
relatedToType="Return__c">
<messaging:htmlEmailBody >
<c:Pending_Letter caseId="{!relatedTo.Case__r.Id}" contactId={!relatedTo.Case__r.Contact.Id}"/>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Vf Component:
<apex:component access="global" controller="Reminder_Letter">
<apex:attribute name="contactId" type="Id" description="Id of the Contact" assignTo="{!contact}"/>
<apex:attribute name="caseId" type="Id" description="Id of the Case" assignTo="{!cId}"/>
{!customSettings.Line1__c} <br/>
{!customSettings.Line2__c}
<apex:dataTable value="{!returnList}" var="pr" id="dtCaseInfo"
rowClasses="odd,even" styleClass="tableClass">
<apex:column >
<apex:facet name="header"> Serial Number </apex:facet>
<apex:outputText value="{!pr.Issue__r.SerialNumber__c}"/>
</apex:column>
</apex:dataTable>
{!customSettings.Line3__c}
<br/>
<br/>
{!customSettings.Line4__c}
</apex:component>
Controller:
public class ADC_Ctrl_Reminder_Letter {
public Id cId {get;set;}
public Id contact {get;set;}
//customSettings
Reminder_Letter__c customSettings{get;set;}
List<Product_Return__c> ReturnList;
public ADC_Ctrl_Reminder_Letter(){
customSettings = Reminder_Letter__c.getInstance('USA');
}
//List to be used in VF
Public List<Product_Return__c> getReturnList(){
if(cId != null) {
productReturnList = new List<Product_Return__c>([Select
Id, Name,Return_Status__c, Case__c, Issue__c
FROM
Return__c
WHERE Return_Status__c IN ('Pending')
AND Case__c =: cId] );
return ReturnList;
}
return null;
}
}