<apex:page showheader="false" controller="Consent_Records_Ctrls" doctype="html-5.0" tabStyle="case"> <apex:form > <apex:pageBlock title="Redelivery Report Developed @ Neosoft" > <apex:pageBlockSection title="Consent Records" > <apex:input type="date" value="{!startDate}" label="From Date"> <!-- <apex:actionSupport event="onchange" action="{!ConsentDisplay}" reRender="abc"> </apex:actionSupport>--> </apex:input> <apex:input type="date" value="{!EndDate}" label="To Date"> <!--<apex:actionSupport event="onchange" action="{!ConsentDisplay}" reRender="abc"> </apex:actionSupport>--> </apex:input> <apex:commandButton value="Filter" action="{!consentFilter}" /> </apex:pageBlockSection> <apex:pageBlockSection title="All Consent Records" > <apex:pageBlockTable value="{!allCon}" var="con" > <!--<Apex:column value="{!con.Account__r.Id}" headerValue="Account Id"/>--> <apex:column value="{!con.coutOfid}" headerValue="Eerdere Aanvragen TL"/> <Apex:column value="{!con.accid}" headerValue="AccountId"/> <Apex:column value="{!con.Name}" headerValue="Aanvrag"/> <apex:column value="{!con.Salutation}" headerValue="Aanhef"/> <apex:column value="{!con.FirstName}" headerValue="Voornam"/> <apex:column value="{!con.Initials}" headerValue="Initilen"/> <apex:column value="{!con.LastNamePrefix}" headerValue="Voorvoegsel"/> <apex:column value="{!con.LastName}" headerValue="Achternaam"/> <apex:column value="{!con.ElectricityCurrentRedeliveryNum}" headerValue="TL"/> <apex:column value="{!con.ElectricityCurrentRedeliveryLowNum}" headerValue="TL(laag)"/> <apex:column value="{!con.MeterTariffChoice}" headerValue="Meter"/> <apex:column value="{!con.PhoneNumber}" headerValue="Telefoon"/> <apex:column value="{!con.EmailAddress}" headerValue="Email"/> <apex:column value="{!con.Main_Street}" headerValue="Straat"/> <apex:column value="{!con.Main_Number}" headerValue="Huisnr."/> <!--<apex:column value="{!con.Main_Addition__c}" headerValue="Toev."/>--> <apex:column value="{!con.Main_PostalCode}" headerValue="Postcode"/> <apex:column value="{!con.Main_City}" headerValue="Plaatsnaam"/> <apex:column value="{!con.Exclude_from_Surveys}" headerValue="Geen enquetes"/> //The Count of Redelivery-Consents on ParentAccount Eerdere Aanvragen TL count needs to be displayed and below all are the values of the oldest records of the consent__C // <apex:column value="{!con.accid}" headerValue="Oudste TL-aanvraag Id"/> <apex:column value="{!con.Name}" headerValue="Oudste TL-aanvraag"/> <apex:column value="{!con.ElectricityCurrentRedeliveryNum}" headerValue="TL oud"/> <apex:column value="{!con.ElectricityCurrentRedeliveryLowNum}" headerValue="TL oud (laag)"/> //apart from that then these values are required [1][Basic] [1][Base Usage] [1][Old Con] [2][Person Name] [2][ContactInfo] [2][Address] in two lines// </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> Controller Code : public class Consent_Records_Ctrls { public date startDate{get;set;} public date EndDate{get;set;} public long store{get;set;} public List<WrapConsent> allCon{get;set;} public List<Consent__c> allConRecs{get;set;} public map<string,string>MapAccAr=new map<string,string>(); public PageReference consentFilter() { for (AggregateResult groupedResults: [SELECT Count(Id)ids,Account__r.Id accids FROM Consent__c where CreatedDate >=:startDate AND LastModifiedDate <=:EndDate GROUP BY Account__r.Id]) { // System.debug('ID' + ar.get('ids')); // System.debug('Count Id' + ar.get('expr0')); MapAccAr.put(string.valueof(groupedResults.get('accids')),string.valueof(groupedResults.get('ids'))); } for(Consent__C consent:[select account__r.id,name,Salutation__c,FirstName__c ,Initials__c,LastNamePrefix__c,LastName__c, ElectricityCurrentRedeliveryNum__c,ElectricityCurrentRedeliveryLowNum__c ,MeterTariffChoice__c, PhoneNumber__C,EmailAddress__c,Main_Street__c,Main_Number__c,Main_Addition__c,Main_PostalCode__c, Main_City__c,Exclude_from_Surveys__c from Consent__c where CreatedDate >=:startDate AND CreatedDate<=:EndDate and ElectricityCurrentRedeliveryNum__c > 0 and Status__c = 'Processed']){ WrapConsent wrapCon=new WrapConsent(); if(MapAccAr.containsKey(string.valueof(consent.account__r.id))) wrapCon.coutOfid=MapAccAr.get(string.valueof(consent.account__r.id)); wrapCon.accid=string.valueof(consent.account__r.id); wrapCon.name=consent.name; wrapCon.Salutation=consent.Salutation__c; wrapCon.FirstName=consent.FirstName__c; wrapCon.Initials=consent.Initials__c; wrapCon.LastNamePrefix=consent.LastNamePrefix__c; wrapCon.LastName=consent.LastName__c; wrapCon.ElectricityCurrentRedeliveryNum=string.valueof(consent.ElectricityCurrentRedeliveryNum__c); wrapCon.ElectricityCurrentRedeliveryLowNum=string.valueof(consent.ElectricityCurrentRedeliveryLowNum__c); wrapCon.MeterTariffChoice=consent.MeterTariffChoice__c; wrapCon.PhoneNumber=string.valueof(consent.PhoneNumber__C); wrapCon.EmailAddress=consent.EmailAddress__c; wrapCon.Main_Street=consent.Main_Street__c; wrapCon.Main_Street=consent.Main_addition__c; wrapCon.Main_Number=string.valueof(consent.Main_Number__c); wrapCon.Main_PostalCode=consent.Main_PostalCode__c; wrapCon.Main_City=consent.Main_City__c; wrapCon.Exclude_from_Surveys=string.valueof(consent.Exclude_from_Surveys__c); } return null; return consentFilter(); } public List<WrapConsent> getConsentlist() { return allCon; } public void ConsentDisplay() { if(startDate!=NULL&&EndDate!=NULL) { if(startDate!=NULL&&EndDate!=NULL) { store=1; } else { store=0; } } } public class WrapConsent{ public string coutOfid{set;get;} public string accid{set;get;} public string name{set;get;} public string Salutation{set;get;} public string FirstName{set;get;} public string Initials{set;get;} public string LastNamePrefix{set;get;} public string LastName{set;get;} public string ElectricityCurrentRedeliveryNum{set;get;} public string ElectricityCurrentRedeliveryLowNum{set;get;} public string MeterTariffChoice{set;get;} public string PhoneNumber{set;get;} public string EmailAddress{set;get;} public string Main_Street{set;get;} public string Main_Number{set;get;} public string Main_PostalCode{set;get;} public string Main_City{set;get;} public string Exclude_from_Surveys{set;get;} public string Main_addition{set;get;} } }