Skip to main content
Hello, 

I have a fairly simple VF email template that lists opportunities that are in the Stage "Contract Sent" - is there a way that I can easily make the table rows sort by one of the column values?  

Here is my table: 

 

<table cellpadding="5" style="border-collapse: collapse;table-layout:fixed" width="1200" border="1" >

<tr>

<td style="background-color: ⌗C6D4D4; color: ⌗040404" width="100">

<b>Opportunity Name</b>

</td>

<td style="background-color: ⌗C6D4D4; color: ⌗040404" width="100">

<b>Company Name</b>

</td>

<td style="background-color: ⌗C6D4D4; color: ⌗040404" width="100">

<b>Vertical</b>

</td>

<td style="background-color: ⌗C6D4D4; color: ⌗040404" width="100">

<b>Contract Age</b>

</td>

<td style="background-color: ⌗C6D4D4; color: ⌗040404" width="100">

<b>Contract Sent</b>

</td>

<td style="background-color: ⌗C6D4D4; color: ⌗040404" width="450">

<b>Next Step</b>

</td>

<td style="background-color: ⌗C6D4D4; color: ⌗040404" width="100">

<b>Lead Source</b>

</td>

<td style="background-color: ⌗C6D4D4; color: ⌗040404" width="50">

<b>Prob%</b>

</td>

<td style="background-color: ⌗C6D4D4; color: ⌗040404" width="100">

<b>Owner</b>

</td>

</tr>

<apex:repeat value="{!relatedTo.Optys__r}" var="cs">

<apex:outputText rendered="{!IF(cs.OwnerStage__c ='Marino-Contract Sent',true,false)}">

<tr>

<td width="100">

<a href="https://na2.salesforce.com/{!cs.id}">{!cs.name}</a>

</td>

<td width="100">

{!cs.Company_Name__c}

</td>

<td width="100">

{!cs.Vertical__c}

</td>

<td width="100">

{!TEXT(cs.Contract_Age__c)}

</td>

<td width="100">

{!MONTH(cs.Contract_SENT__c)}/{!DAY(cs.Contract_SENT__c)}/{!YEAR(cs.Contract_SENT__c)}

</td>

<td width="450">

{!cs.NextStep}

</td>

<td width="100">

{!cs.LeadSource}

</td>

<td width="50">

{!cs.Probability}%

</td>

<td width="100">

{!cs.Owner_Name__c}

</td>

</tr>

</apex:outputText>

</apex:repeat>

</table>

I'd like to sort the rows in the table by contract_age__c ascending.  

Is there any way to do this with out going down the wormhole of controllers, components, etc? 

Thanks in advance!

John
1 Antwort
  1. 12. Apr. 2016, 15:27
    Hi John,

    You can get this working using SOQL queries. So while querying record from Optys__r record you need to use ORDER BY your_column_name.

    Exa - 

    [SELECT Id, Name, (SELECT Id, Name FROM Contacts ORDER BY Name) FROM Account]

    Do let me know if you need more help.

    Thanks,

    Naval
0/9000