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
SK R.ax1448SK R.ax1448 

how to sort activity histories based on last modified date

Hi All,

I have replaced Activity History related list with a VF page using Standard Controller, the issue is data is not displaying order by, I want to sort the activity histories based on lastModified date/time, how to do that ? any help is highly appreciated.


Here is the VF:


<apex:page standardController="Case" extensions="ActivityHistory_cls">
 <apex:form >
     <apex:pageBlock title="Activity History" >
        <apex:pageBlockTable value="{!Case.ActivityHistories}" var="list" id="theId">
            <apex:column headerValue="Subject"><apex:outputField value="{!list.Subject}"/> </apex:column>
            <apex:column headerValue="Name"><apex:outputField value="{!list.WhoId}"/> </apex:column>
            <apex:column headerValue="Task"> <apex:outputField value="{!list.IsTask}"/> </apex:column>
            <apex:column headerValue="Due Date"> <apex:outputField value="{!list.ActivityDate}"/> </apex:column>
            <apex:column headerValue="LastModified Date/Time">  <apex:outputField value="{!list.LastModifiedDate}"/></apex:column>


Thanks in advance,



in class you should write a query

Public List<ActivityHistories> acv{get;set;}


acv=[select id,........from ......          Order by LastModifiedDate];


like this


By using this query you need to access Pageblock table values...






Thanks for the reply prem.


I have used child relationship to get/display the values on page, i.e. {!Case.ActivityHistories.Status} with out querying. I dont know why it is not displaying standard order by, is it possible with out writing a query in a controller class.





I don't think so..

But how it is Possible..

We should write a query must i think..





SK R.ax1448SK R.ax1448
It works without a query .
In the above VF page, controller is taken to override "VeiwAll" button only,