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 

Visualforce Email Template Issue

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

liron169liron169

Possible solution:
try

public List<Problem__c> getserials()

{

List<Problem__c> tempList=[

SELECT case_product_name__c, serial_number__c

FROM problem__c

where case_id__c =: caseId];

 

serials=tempLisy;

 

return serials;
}

Jeff_Rogers.ax1383Jeff_Rogers.ax1383

Thank you for the response, unfortunately data still does not display.  Any other ideas?  I also put a system.debu(caseId) statement right before the query, but no debug logs are created (under my user)... why would that be?

liron169liron169
amm....maybe need the id in the reapet.
Don't sure if that's the problem, but worth to try.

<apex:repeat value="{!serials}" var="serial" id="serReapet">


Jeff_Rogers.ax1383Jeff_Rogers.ax1383
Using the id attributed did not help either. Bummer!
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