I am working on a custom controller to sort the below apex:repeat list in Desc order by BMCServiceDesk__date__c
or CreatedDate
. Part of my VF email template and Controller code is below. I am getting a compile error of "Return value must be of type: List" in my dev console. Thanks everyone for your help, much appreciated.
// apex:repeat component to call related list 'Notes' from Incident History object, but the order it display in the email is Ascending order (the oldest on top), I want to sort it in Descending order by the Date and time field BMCServiceDesk__date__c where the newest note on top. //
Here are my revised codes:
VF page
<tr>
<th colspan="4"><strong>Update</strong></th>
<c:sortedNoteController ></c:sortedNoteController>
</tr>
Class
public class sortedController {
public ID incidentId {get; set;}
public List<BMCServiceDesk__IncidentHistory__c> getIncidentHistories() {
Return [
SELECT BMCServiceDesk__note__c
FROM BMCServiceDesk__IncidentHistory__c
WHERE BMCServiceDesk__actionId__c = 'Notes' AND BMCServiceDesk__incidentId__c =: this.incidentId
ORDER BY BMCServiceDesk__date__c DESC
];
}
}
Component
<apex:component controller="sortedController" access="global">
<apex:attribute name="IncidentHistoryID" type="ID" assignTo="{!incidentId}" description="Note ID"/>
<table>
<apex:repeat value="{!IncidentHistories}" var="CurrItem">
<apex:outputPanel rendered="{!CurrItem.BMCServiceDesk__actionId__c = 'Notes'}">
<tr>
<td colspan="4" class="hdr"><pre>{!CurrItem.BMCServiceDesk__note__c}</pre>
<apex:outputText value="{0,date,MM/dd/yyyy h:mm a}">
<apex:param value="{!CurrItem.BMCServiceDesk__date__c - (5/24)}"/></apex:outputText>
</td>
</tr>
</apex:outputPanel>
</apex:repeat>
</table>
</apex:component>