/** @ Author : Sourabh Yerawar @ Purpose : 1] Controls the page --> ClosedCases 2] Fetches list of closed cases along with details. */
public with sharing class ClosedCasesController {
<!--- Class Code --->
/**
@ Author : Sourabh Yerawar
@ Purpose : 1] Controls the page --> ClosedCases
2] Fetches list of closed cases along with details.
*/
public with sharing class ClosedCasesController {
public List<AggregateResult> listOfClosedCases { get; set; }
public ClosedCasesController() {
initializePage();
}
private void initializePage() {
listOfClosedCases = getClosedCases();
}
private List<AggregateResult> getClosedCases() {
List<AggregateResult> listOfClosedCases = new List<AggregateResult>();
try {
listOfClosedCases = [ SELECT Case_Closed_By__c, Type, COUNT(Id) numberOfClosedCases
FROM Case
WHERE isClosed = TRUE
Group BY Case_Closed_By__c, Type
];
}
catch( Exception e ) {
displayMessageFromException( e );
}
return listOfClosedCases;
}
/*
@ Purpose : Fetches and displays an exception message.
@ Parameter : Exception.
@ Return Type : String [ Details of the exception ].
*/
public static String displayMessageFromException( Exception e ) {
String strErrorMessage = '\nError Message:-{0}\nError LineNumber:-{1}';
List<String> listOfMessageTokens = new List<String>{ e.getMessage(), String.valueOf( e.getLineNumber() ) };
strErrorMessage = String.format(strErrorMessage, listOfMessageTokens);
system.debug(strErrorMessage);
return strErrorMessage;
}
}
<apex:page controller="ClosedCasesController" showHeader="False" sidebar="False" standardStylesheets="True">
}
<!-- Page Code --->
<!--
@ Author : Sourabh Yerawar
@ Purpose : Displays list of closed cases along with details.
@ Page Name : ClosedCases
-->
<apex:page controller="ClosedCasesController" showHeader="False" sidebar="False" standardStylesheets="True">
<apex:form >
<apex:pageBlock title="Closed Cases">
<apex:pageBlockTable value="{! listOfClosedCases }" var="recordCase">
<apex:column >
<apex:outputText value="{! recordCase[ 'Case_Closed_By__c' ] }"/>
<apex:facet name="header">Case Closed By </apex:facet>
</apex:column>
<apex:column >
<apex:outputText value="{! recordCase[ 'Type' ] }"/>
<apex:facet name="header">Case Type </apex:facet>
</apex:column>
<apex:column >
<apex:outputText value="{! recordCase[ 'numberOfClosedCases' ] }"/>
<apex:facet name="header">Number Of Closed Cases </apex:facet>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>