You need to sign in to do that
Don't have an account?
bdardin
Custom Controller Issue for Component in Visualforce Email Template
I have been searching and googling like crazy trying to resolve this. I wrote an email template with a component and custom controller, but I can't get any of the values set in the controller to show up when I try to test it via the Send Test and Verify Merge Fields button. I've read many posts here in this forum about this issue and have implemented everything I read but I'm STILL not getting anything, so there must be something else I'm missing.
Email Template
<messaging:emailTemplate subject="How Did We Do?" recipientType="Contact" relatedToType="SVMXC__Service_Order__c"> <messaging:htmlEmailBody > <html> <body> <style type="text/css"> body {color:black; font-family:arial; font-size:12px} </style> Hello {!Recipient.Name},<br/><br/> <c:SurveyEmailComponent_MEC emailWOId="{!relatedTo.Id}"/> </body> </html> </messaging:htmlEmailBody> </messaging:emailTemplate>
Component
<apex:component controller="SurveyEmailController" access="global"> <apex:attribute name="emailWOId" description="Passes the ID of the WO to the custom controller" type="Id" assignTo="{!woID}"/> <apex:outputText >We want to continue to improve by learning how we did on our recent service completed for you on {!completedDate}.<br/><br/> We would be grateful if you took 2 minutes to complete a very short survey by clicking the link below: </apex:outputText><br/><br/> <apex:outputLink value="http://mckinley.force.com/timbasurveys__survey?id=a2LE0000000Td4qMAC&cId={!contactID}&wf=yes">Service Follow Up Survey</apex:outputLink><br/><br/> <apex:outputText >Thank you,<br/> {!techName} </apex:outputText><br/> <apex:image value="{!photoURL}"/> </apex:component>
Controller
public class SurveyEmailController { public ID woID {get; set;} public SVMXC__Service_Order__c wo {get; set;} public ID contactID {get; set;} public String techName {get; set;} public String photoURL {get; set;} public String completedDate {get; set;} public SurveyEmailController() { } public SVMXC__Service_Order__c getWO() { wo = [SELECT Id, SVMXC__Contact__c, Technician_completed_WO_Date_Time__c, SVMXC__Group_Member__r.Name, SVMXC__Group_Member__r.SVMXC__Salesforce_User__r.SmallPhotoUrl FROM SVMXC__Service_Order__c WHERE Id = :woID]; return wo; } public String getPhotoURL() { photoURL = wo.SVMXC__Group_Member__r.SVMXC__Salesforce_User__r.SmallPhotoUrl; return photoURL; } public String getCompletedDate() { datetime techCompDate = datetime.valueOf(wo.Technician_completed_WO_Date_Time__c); if(techCompDate != null) { completedDate = techCompDate.format('MM-dd-yyyy', 'PST'); } else { completedDate = System.Now().format('MM-dd-yyyy', 'PST'); } return completedDate; } public ID getContactID() { contactID = wo.SVMXC__Contact__c; return contactID; } public String getTechName() { techName = wo.SVMXC__Group_Member__r.Name; return techName; } }