I am having lookup relationship between case and .Case_PO custom object. I am using site to create new case record with .Case_PO child record also. After creating a new case record with related list records I email this to Case Contact. For this I am using vf email template it works fine and email is going to the case contact. But in the email I am not getting the information of related list record, PO table is showing empty for that case but in the org I am having PO for that case. I am sending email to Case contact using workflow rule.Can any one tell how to all the realted list record when creating a case and email this information . Here I have attached vf email template for this.
VF Email Template:
<messaging:emailTemplate subject="DC Receiving Query Submitted – Case Number: {!relatedTo.CaseNumber} DC: {!relatedTo.Distribution_Centre__r.DC_Number__c} - Vendor - {!relatedto.Vendor_Number__r.Vendor_Number__c} {!relatedto.Vendor_Number__r.Name} " recipientType="Contact" relatedToType="Case">
<messaging:htmlEmailBody >
<html>
<body>
<STYLE type="text/css">
TH {font-size: 11px; font-face: arial;background: #CCCCCC;
border-width: 0; text-align: center }
TD {font-size: 11px; font-face: verdana }
TABLE {border: solid #CCCCCC; border-width: 0}
TR {border: solid #CCCCCC; border-width: 0}
</STYLE>
<font face="arial" size="2">
<!--<p>Hi {!recipient.name},</p>-->
<p>Hi {!relatedTo.DC_Contact_Name__r.Name},</p>
<p>Please see below confirming details of your DC receiving query raised {!relatedTo.Created_DateTime__c}.For your reference, the case number for this query is {!relatedTo.CaseNumber} .</p>
<table cellspacing="0" cellpadding="0" border="0" >
<tr>
<td align="left"><p style="font-family:Helvetica Neue,arial;font-size:12px;color:#333333;line-height:17px;padding-left:2px;">
<b>DC:</b> {!relatedTo.Distribution_Centre__r.DC_Number__c}<br></br>
<b>Vendor Number:</b> {!relatedto.Vendor_Number__r.Vendor_Number__c}<br></br>
<b>Vendor Name:</b> {!relatedto.Vendor_Number__r.Name}<br></br>
<b>Query Type :</b> <apex:outputField value="{!relatedto.Type}"/><br></br>
</p>
</td>
</tr>
</table>
<table colunm = "6" border = "5">
<tr >
<th>PO Number(s)</th>
<th> Buyer Name</th>
<th> Event Number </th>
<th> Container Number </th>
<th> Number Pallets / Cartons </th>
<th> Booking Date / Time</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Case_PO__r}">
<tr>
<td>{!cx.PO__r.Name}</td>
<td>{!cx.PO__r.Department_Team__r.Name}</td>
<td>{!cx.PO__r.Event_Number__c}</td>
<td>{!cx.PO__r.Container_Number__c}</td>
<td>{!cx.PO__r.Number_Pallets_Cartons__c}</td>
<td>{!cx.PO__r.Booking_Date_Time__c}</td>
</tr>
</apex:repeat>
</table>
<br/>
<br/>
You will receive a further updates as your request is reviewed.<br/>
<br/>
<br/>
<b> Kind Regards,</b><br/>
Capacity and Scheduling Team,<br/>
Big W,<br/>
Australia.<br/>
</font>
</body>
</html>
</messaging:htmlEmailBody>
<messaging:plainTextEmailBody >
Hi {!relatedTo.DC_Contact_Name__r.Name},
Please see below confirming details of your DC receiving query raised {!relatedTo.CreatedDate}.For your reference, the case number for this query is {!relatedTo.CaseNumber}
[ PO Number(s) ] -[ Buyer Name ]- [ Event Number] - [ Container Number] -[ Number Pallets / Cartons] - [ Booking Date / Time ]
<apex:repeat var="cx" value="{!relatedTo.Big_W_Case_PO__r}">
[ {!cx.PO__r.Name} ]-[{!cx.PO__r.Department_Team__r.Name}] - [{!cx.PO__r.Event_Number__c} ] - [ {!cx.PO__r.Container_Number__c} ] - [{!cx.PO__r.Number_Pallets_Cartons__c}] - [{!cx.PO__r.Booking_Date_Time__c}]
</apex:repeat>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>