Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
public with sharing class TBN_PicklistReport { //Variables public Map<String, map<String, Integer>> ratingVsRecordCountMapOfmap { get;set; } List<SObject> lstSobjectResult; String piklistName; String objName; public TBN_PicklistReport() { //Do-Initialization ratingVsRecordCountMapOfmap = new Map<String, map<String, Integer>>(); lstSobjectResult = new List<SObject>(); piklistName = 'StageName'; objName = 'Opportunity'; getRecordCounts(); } public void getRecordCounts() { String objName = 'Task'; //ApexPages.currentPage().getParameters().get('objectName'); String piklistNameRow = 'Priority'; //Apexpages.currentPage().getParameters().get('picklist1'); String piklistNameCol = 'Status'; //Apexpages.currentPage().getParameters().get('picklist2'); system.debug('--objName--' + objName); system.debug('--piklistNameRow--' + piklistNameRow); system.debug('--piklistNameCol--' + piklistNameCol); //Get all picklist value from schema Map<String, String> mapAPInameVsLabelRow = getSchemaPicklist(objName, piklistNameRow); Map<String, String> mapAPInameVsLabelCol = getSchemaPicklist(objName, piklistNameCol); //Initialize all Priority and Status combinations by Zero. for(String strKeyRow : mapAPInameVsLabelRow.keySet()) { Map<String, Integer> mapKeyColVsValue = new Map<String, Integer>(); for(String strKeyCol : mapAPInameVsLabelCol.keySet()) { mapKeyColVsValue.put(mapAPInameVsLabelCol.get(strKeyCol), 0); } ratingVsRecordCountMapOfmap.put(mapAPInameVsLabelRow.get(strKeyRow),mapKeyColVsValue); } //Get all Task for Priority, Status lstSobjectResult = [Select Priority, Status From Task Where Priority != Null AND Status != Null]; if(!lstSobjectResult.isEmpty()) { for(SObject objTest : lstSobjectResult) { String priorityPicklistVal = (String)objTest.get(piklistNameRow); String statusPicklistVal = (String)objTest.get(piklistNameCol); if(ratingVsRecordCountMapOfmap.containsKey(priorityPicklistVal)) { Map<String, Integer> innermap = ratingVsRecordCountMapOfmap.get(priorityPicklistVal); //if(!innermap.isEmpty()) { if(innermap.containsKey(statusPicklistVal)) { Integer count = innermap.get(statusPicklistVal) + 1; innermap.put(statusPicklistVal, count); } else { innermap.put(statusPicklistVal, 1); } ratingVsRecordCountMapOfmap.put(priorityPicklistVal, innermap); //} } else { Map<String, Integer> innermap = new Map<String, Integer>(); innermap.put(statusPicklistVal, 1); ratingVsRecordCountMapOfmap.put(priorityPicklistVal, innermap); } } } system.debug('---> ' + ratingVsRecordCountMapOfmap); //return ratingVsRecordCountMapOfmap; } private Map<String, String> getSchemaPicklist(String objName, String piklistName) { Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(objName).getDescribe().fields.getMap(); List<Schema.PicklistEntry> ple = objectFields.get(piklistName).getDescribe().getPicklistValues(); Map<String, String> mapAPInameVsLabel = new Map<String, String>(); for( Schema.PicklistEntry pickListVal : ple){ //pickListLabelsList.add(pickListVal.getLabel()); //pickListValuesList.add(pickListVal.getValue()); mapAPInameVsLabel.put(pickListVal.getValue(), pickListVal.getLabel()); } return mapAPInameVsLabel; } }
<apex:page controller="TBN_PicklistReport"> <apex:form > <apex:pageBlock > <apex:outputPanel rendered="{!IF(ratingVsRecordCountMapOfmap == NULL, false, true)}"> <apex:repeat value="{!ratingVsRecordCountMapOfmap}" var="mapKey"> <br/> {!mapKey} <apex:repeat value="{!ratingVsRecordCountMapOfmap[mapKey]}" var="innerMapKey"> <!--{!innerMapKey} --> <!-- It will show header--> {!ratingVsRecordCountMapOfmap[mapKey][innerMapKey]} </apex:repeat> <br/> </apex:repeat> <apex:commandButton value="Back" onclick="window.location.top.reload();" /> </apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page>
you can try this code
Might be needed some change in VF code
Class: Visualforce Page:
Let me know if it works for you.
Thanks
Niraj
Thank you Niraj for giving the solution but the requirement I want to display vf page like this. it should look like table.
new working escalated
high 1 2 0
low 5 1 2
medium 0 5 4