You need to sign in to do that
Don't have an account?
fe_alden
Suppressing Related Lists on VF Email Template When There are No Results
I have a VF email template that displays the related list great. However, I want to supress the entire section (including the header) if there are no rows returned. How would I go about achieving this?
Here is the existing code.
Thanks
<messaging:emailTemplate subject="New Subscription for {!relatedTo.Account.Name}" recipientType="Contact" relatedToType="ServiceContract">
<messaging:htmlEmailBody >
<span class="sectionTitle">SUBSCRiPTION DETAIL</span><br/>
<apex:panelGrid columns="2">
<apex:outputLabel for="CustomerName" value="End Customer:"/>
<apex:outputText id="CustomerName" value="{!relatedTo.Account.Name}"/>
<apex:outputLabel for="CustomerID" value="Account ID:"/>
<apex:outputText id="CustomerID" value="{!relatedTo.Account.Customer_ID__c}"/>
<apex:outputLabel for="PONumber" value="PO Number: "/>
<apex:outputText id="PONumber" value="{!relatedTo.PO__c}"/>
</apex:panelGrid>
<p>
</p>
<span class="sectionTitle">Support</span><br/>
<table border="0" cellspacing="0" cellpadding="4" class="list">
<tr>
<th>Serial Number</th>
<th>Product</th>
<th>Type</th>
<th>Start Date</th>
<th>End Date</th>
</tr>
<apex:repeat var="SN" value="{!relatedTo.ContractLineItems}">
<apex:outputPanel layout="none" rendered="{!SN.PricebookEntry.Product2.License_Feature__r.Name == Support'}">
<tr>
<td> {!SN.Asset.Name} </td>
<td> {!SN.PricebookEntry.Product2.Name} </td>
<td> {!SN.PricebookEntry.Product2.Level__c} </td>
<td> {!month(SN.StartDate)}/{!day(SN.StartDate)}/{!year(SN.StartDate)} </td>
<td> {!month(SN.EndDate)}/{!day(SN.EndDate)}/{!year(SN.EndDate)} </td>
</tr>
</apex:outputPanel>
</apex:repeat>
</table>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
<messaging:htmlEmailBody >
<span class="sectionTitle">SUBSCRiPTION DETAIL</span><br/>
<apex:panelGrid columns="2">
<apex:outputLabel for="CustomerName" value="End Customer:"/>
<apex:outputText id="CustomerName" value="{!relatedTo.Account.Name}"/>
<apex:outputLabel for="CustomerID" value="Account ID:"/>
<apex:outputText id="CustomerID" value="{!relatedTo.Account.Customer_ID__c}"/>
<apex:outputLabel for="PONumber" value="PO Number: "/>
<apex:outputText id="PONumber" value="{!relatedTo.PO__c}"/>
</apex:panelGrid>
<p>
</p>
<span class="sectionTitle">Support</span><br/>
<table border="0" cellspacing="0" cellpadding="4" class="list">
<tr>
<th>Serial Number</th>
<th>Product</th>
<th>Type</th>
<th>Start Date</th>
<th>End Date</th>
</tr>
<apex:repeat var="SN" value="{!relatedTo.ContractLineItems}">
<apex:outputPanel layout="none" rendered="{!SN.PricebookEntry.Product2.License_Feature__r.Name == Support'}">
<tr>
<td> {!SN.Asset.Name} </td>
<td> {!SN.PricebookEntry.Product2.Name} </td>
<td> {!SN.PricebookEntry.Product2.Level__c} </td>
<td> {!month(SN.StartDate)}/{!day(SN.StartDate)}/{!year(SN.StartDate)} </td>
<td> {!month(SN.EndDate)}/{!day(SN.EndDate)}/{!year(SN.EndDate)} </td>
</tr>
</apex:outputPanel>
</apex:repeat>
</table>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
You can use rendered and the "size" property of a list:
I tried using this code, but its giving me an error, below is my code and here is the error:
Error: Incorrect parameter for operator '>'. Expected Object, received Number
<apex:outputPanel rendered="{!relatedTo.Diagnosticos_Cita__r >0}}">
<p> <big><b> Diagnósticos</b></big></p>
<BR></BR>
<table border="1" >
<tr >
<th>Padecimiento </th><th>Comentarios </th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Diagnosticos_Cita__r}">
<tr>
<td>{!cx.Diagnostico__r.Name}</td>
<td>{!cx.Comentarios__c}</td>
</tr>
</apex:repeat>
</table>
</apex:outputPanel>
relatedTo.Diagnosticos_Cita__r is a reference to an Object.
You probably want:
relatedTo.Diagnosticos_Cita__c
or
relatedTo.Diagnosticos_Cita__r.<some field>
Thanks.
Neither of those work.
The related list is called "Diagnosticos_Cita".
If I try: <apex:outputPanel rendered="{!relatedTo.Diagnosticos_Cita__r.Diagnostico__c >0}}">
I get this error: Error: Unknown property 'VisualforceArrayList.Diagnostico__c'
That exact field is referenced without issues within an apex:repeat
If I try: <apex:outputPanel rendered="{!relatedTo.Diagnosticos_Cita__c >0}">
I get this error: Error: Invalid field Diagnosticos_Cita__c for SObject alodok__Cita__c
There is NO field called Diagnosticos_Cita__c