You need to sign in to do that
Don't have an account?
Custom Controller Issue for Component in Visualforce Email Template
I'm not getting any data to display in my email template when passing the caseId to query the Case_Product_Name and Serial_Number__c fields from the "Problem" object. I do get data when I hard code the caseId in the getSerials setter. Keep in mind the case_id__c field is a string data type on the problem object" (its a formula field to make this email template easier to create intead of building a wrapper classs to get the data... the relationship between the objects are amaster-detail from Case to Case Product to Problem).
Any help would be greatly appreciated! Thanks!
Email Template:
<messaging:emailTemplate subject="test" recipientType="Contact" relatedToType="Case"> <messaging:htmlEmailBody > <c:Case_Product_Serials paramCaseId="{!relatedTo.Id}"/> </messaging:htmlEmailBody> </messaging:emailTemplate>
Component:
<apex:component controller="caseProductSerials" access="global"> <apex:attribute name="paramCaseId" type="Id" description="Case Id parameter" assignTo="{!caseId}"/> <apex:repeat value="{!serials}" var="serial"> <apex:outputText value="{!serial.case_product_name__c}" /> </apex:repeat> </apex:component>
Controller:
public class caseProductSerials { Public Id caseId {get;set;} Public List<Problem__c> serials = new List<Problem__c>(); public caseProductSerials() { } public List<Problem__c> getserials(){ return [SELECT case_product_name__c, serial_number__c FROM problem__c where case_id__c =: caseId]; //'500Q0000003woSF']; } }
Well it looks like the caseId that was being being set in the controller was an 18 digit Id and the query only returned results with the 15 digit Id, so I just truncated the last 3 digits and called it good.
Thanks for your help!
All Answers
Did you debug and see what value does the variable 'caseId' store?
Thank you for the response. I put a system.debug(caseId) statement right before the query, but no debug logs are created (under my user)... why would that be?
Well it looks like the caseId that was being being set in the controller was an 18 digit Id and the query only returned results with the 15 digit Id, so I just truncated the last 3 digits and called it good.
Thanks for your help!