You need to sign in to do that
Don't have an account?
Visualforce Email: RENDER RELATED LIST TABLE CONDITIONALLY
Hi,
I've got a visualforce email that shows some fields from a custom object and I've placed a table in there to show related Note records.
This all works fine in test. But I want to take it one step further and only show the table with the related Note records only if there are any. Is there a way to do this without writing a custom controller?
Also, if anyone knows any good documentation with tips for using "render=" in creative ways like this. If I want to find ways others use "render", such as putting in IF statements and the like, I have to scan through the boards here which isn't ideal
I'd love to say render="{! IF(COUNT({relatedTo.Notes}) > 0, TRUE, FALSE )}"
Any ideas?
<messaging:emailTemplate recipientType="User" relatedToType="DAM_Digital_Asset__c" subject="Asset Approval Needed: {!relatedTo.name} {!relatedTo.Content_Title__c}" replyTo="no-reply@makepositive.com" > <messaging:htmlEmailBody > <html> <body> <style type="text/css"> body {font-family: Arial; size: 8pt } table { font-family: Arial; size: 8pt border-width: 1px; border-spacing: 3px; border-style: none; border-color: #FFFFFF; } td { font-family: Arial; size: 8pt border-width: 1px; padding: 3px; border-style: none; border-color: #000000; background-color: #FFF8C6; } th { font-family: Arial; size: 8pt color: #FFEECC; border-width: 1px ; padding: 3px ; border-style: none ; border-color: #FFFFFF; background-color: #ECE5B6; } </style> <font face="arial" size="2"> <!-- <apex:image id="Logo" value="https://na1.salesforce.com/servlet/servlet.ImageServer?id=015A0000001IO1X&oid=00DA00000009Ts6" /> --> <p>Dear {!recipient.Name},</p> <p>Your approval is needed for the following Asset: {!relatedTo.name} {!relatedTo.Content_Title__c}. Click here to view: {relatedTo.Link} </p> <table border="0" > <tr> <th style="border:none windowtext 1.0pt; font-family: Arial; font-size: 10pt">Note</th> <!-- <th style="border:solid windowtext 1.0pt; font-family: Arial; font-size: 10pt">Created Date</th> --> <th style="border:none windowtext 1.0pt; font-family: Arial; font-size: 10pt">Creator Email</th> </tr> <apex:repeat var="nt" value="{!relatedTo.Notes}"> <tr> <td width="2000" style="border:none windowtext 1.0pt; font-family: Arial; font-size: 10pt">{!nt.Title} {!nt.Body}</td> <!-- <td width="300" style="border:solid windowtext 1.0pt; font-family: Arial; font-size: 10pt">{!nt.CreatedDate}</td> --> <td width="300" style="border:none windowtext 1.0pt; font-family: Arial; font-size: 10pt">{!nt.CreatedBy.Email}</td></tr> </apex:repeat> </table> <p /> </font> </body> </html> </messaging:htmlEmailBody> <messaging:plainTextEmailBody > Dear {!recipient.name}, Below is a list of related notes: <apex:repeat var="nt" value="{!relatedTo.Notes}"> ----------------------- [ {!nt.Title} ] - [ {!nt.CreatedDate} ] - [ {!nt.CreatedBy.email} ] [ {!nt.Body} ] </apex:repeat> </messaging:plainTextEmailBody> </messaging:emailTemplate>
Try the "rendered={! IF(COUNT({relatedTo.Notes}) > 0, TRUE, FALSE )}" instead of render.