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
turbo2ohturbo2oh 

how to limit number of records shown in VF email template

I'm developing a VF email template and I'm showing various related list info via the relatedTo field for an Account but want to limit the number of records shown. Is this possible?

 

Example code

 

<messaging:emailTemplate subject="Call Report" recipientType="User" relatedToType="Account">

  #lots of other stuff here

 

<apex:outputpanel rendered="{!!ISBLANK(relatedTo.Contacts)}">
        <h2>Contacts</h2>
        <apex:dataTable var="c" value="{!relatedTo.Contacts}" columnClasses="columnheaders">
             <apex:column headerValue="Name">{!c.Name} {!c.Suffix__c}</apex:column>
             <apex:column headerValue="Title">{!c.title}</apex:column>
             <apex:column headerValue="Email">{!c.email}</apex:column>
             <apex:column headerValue="Phone">{!c.phone}</apex:column>
        </apex:dataTable>
    </apex:outputpanel>

 Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

The "rows" attribute can limit a dataTable to a limited number of rows. You can use the .size operator on a list to show how many total rows were actually present in the original list.