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
MarniMarni 

How to Control Order of Results that Appear on Visualforce Page

I have a visualforce page that works - it pulls two related lists and shows all the results on a PDF.  My users have asked if I can order the tables that appear so the results are more manageable.  I am having an issue figuring what to add to the page.  I have pasted my VF code below which all works perfectly, I just need a little help figuring out what to add.  Any help on this is greatly appreciated.  Thanks!!

 

 

<apex:page renderas="PDF" standardController="Account" showHeader="false" sidebar="false">
<head>
<style>

@page {
    margin : 70pt .5in .5in .5in;
    @top-center {
        content : "Insured Claim Check";
     }

    @bottom-left {
        content : "LVL Claims Services, LLC - Privileged and Confidential";
    }
    @bottom-right {
        content: "Page " counter(page) " of " counter(pages);
    }
}

div.header {
    position : running(header) ;
}

div.footer {
    position : running(footer) ;
}
</style>
</head>
<p>{!Account.Name} as of {!if(Month(Today())=1,"January","")}{!if(Month(Today())=2,"February","")}{!if(Month(Today())=3,"March","")}{!if(Month(Today())=4,"April","")}{!if(Month(Today())=5,"May","")}{!if(Month(Today())=6,"June","")}{!if(Month(Today())=7,"July","")}{!if(Month(Today())=8,"August","")}{!if(Month(Today())=9,"September","")}{!if(Month(Today())=10,"October","")}{!if(Month(Today())=11,"November","")}{!if(Month(Today())=12,"December","")} {!Day(Today())}, {!Year(Today())}
</p>
<p></p>
<p><u>Related Policies</u></p>
<apex:variable value="{!1}" var="count"/>
<table id="policies" border="1" cellspacing="2" cellpadding="5">
<tr>
<th>#</th>
<th>Policy Number</th>
<th>Policy Period</th>
<th>Underwriter</th>
<th>Underwriting Branch Office</th>
</tr>
<apex:repeat var="rp" value="{!Account.Policies5__r}">
<tr>
<td>{!FLOOR(count)} </td>
<td>{!rp.Name} </td>
<td><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!rp.Effective_Date__c}"/></apex:outputText> - <apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!rp.Expiration_Date__c}"/></apex:outputText></td>
<td>{!rp.Underwriter__r.Name}</td>
<td>{!rp.Underwriting_Branch_Office__c}</td>
<apex:variable var="count" value="{!count+ 1}"/>
</tr>
</apex:repeat>
<p/>
<b>Total number of Policies: </b> {!FLOOR(count-1)}
</table>
<p><u>Related Claims</u></p>
<apex:variable value="{!1}" var="count"/>
<table id="claims" border="1" cellspacing="2" cellpadding="5">
<tr>
<th>#</th>
<th>Claim Number</th>
<th>Insured</th>
<th>Claimant Name</th>
<th>Policy Number</th>
<th>Claim Status</th>
<th>Date Reported</th>
<th>Examiner</th>
</tr>
<apex:repeat var="rc" value="{!Account.Claims__r}">
<tr>
<td>{!FLOOR(count)} </td>
<td>{!rc.Name} </td>
<td>{!rc.Insured_Lookup__r.name}</td>
<td>{!rc.Claimant_Name__c}</td>
<td>{!rc.Policy__r.name}</td>
<td>{!rc.Status__c}</td>
<td><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!rc.Date_Reported__c}"/></apex:outputText></td>
<td>{!rc.Assigned_Examiner2__r.name}</td>
<apex:variable var="count" value="{!count+ 1}"/>
</tr>
</apex:repeat>
<p/>
<b>Total number of Claims: </b> {!FLOOR(count-1)}
</table>
<p/>
</apex:page>

Devendra@SFDCDevendra@SFDC

Hi,

 

You can use ORDER BY for SOQL queries to set the order for results which can be displayed on VF page.

 

You can refer this document: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_orderby.htm

 

Hope this helps :)

 

Thanks,

Devendra

MarniMarni

Unfortunately I haven't been able to use ORDER BY successfully.  There is no SQL statement anywhere in my code and everywhere I have tried to add ORDER BY has ended up causing the code to fail or had the text order by randomly appear throught the report.

 

If the below is my table and I wanted to ORDER BY !rc.Name where would you put that in the code?

 

 

<p><u>Related Claims</u></p>
<apex:variable value="{!1}" var="count"/>
<table id="claims" border="1" cellspacing="2" cellpadding="5">
<tr>
<th>#</th>
<th>Claim Number</th>
<th>Insured</th>
<th>Claimant Name</th>
<th>Policy Number</th>
<th>Claim Status</th>
<th>Date Reported</th>
<th>Examiner</th>
</tr>
<apex:repeat var="rc" value="{!Account.Claims__r}">
<tr>
<td>{!FLOOR(count)} </td>
<td>{!rc.Name} </td>
<td>{!rc.Insured_Lookup__r.name}</td>
<td>{!rc.Claimant_Name__c}</td>
<td>{!rc.Policy__r.name}</td>
<td>{!rc.Status__c}</td>
<td><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!rc.Date_Reported__c}"/></apex:outputText></td>
<td>{!rc.Assigned_Examiner2__r.name}</td>
<apex:variable var="count" value="{!count+ 1}"/>
</tr>
</apex:repeat>
<p/>
<b>Total number of Claims: </b> {!FLOOR(count-1)}
</table>