function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jeff_Rogers.ax1383Jeff_Rogers.ax1383 

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'];
    }
    
}

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Jeff_Rogers.ax1383Jeff_Rogers.ax1383

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

vishal@forcevishal@force

Did you debug and see what value does the variable 'caseId' store?

Jeff_Rogers.ax1383Jeff_Rogers.ax1383

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?

Jeff_Rogers.ax1383Jeff_Rogers.ax1383

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!

 

This was selected as the best answer