0

I have two custom objects by the name of A & B

  • A - has the values like ID- a1, Name= satya
  • B- has a lookup relation like record ID b1 has a field of object A that reflects the ID a1

IN object B there are 10 records with the same ID as of A which is a1. like

(b1,b2,b3,b4,b5,b6,b7,b8,b9.b10)

My visual force page should display the fields like

Count of B // 10 ==== ID of A //a1 ====== ID of B // b1 (first ID if B) -

I am trying to get this resolved but every time I try some thing the result varies.

Controller Class:

public class consent12 {
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 Consent12() {
            allCon=new List<WrapConsent>();
        }
        public void consentFilter() { 
            allCon.clear();

            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])
                MapAccAr.put(string.valueof(groupedResults.get('accids')),string.valueof(groupedResults.get('ids')));

            for(Consent__C consent:[select account__r.id, 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));
                                          //else
                                            //wrapCon.coutOfid='1';
                                        wrapCon.accid=string.valueof(consent.account__r.id);
                                        //wrapCon.id=consent.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);

                                        system.debug('wrapCon ' + wrapCon); //checkin Log your wrapCon is generated Properly with all fields
                                        allCon.add(wrapCon);                                   
                  } //Closing of for looop
            //No return Type is need for this method, as i change to void.
        }

        public void generateConsentlist() {
           consentFilter();
        }

        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;}        
        } 
    }

Unable to add Visual Force Page Code

6
  • 1
    can you post your code whatever you have tried so far. Also, regarding display can you post a excel format picture for understanding Commented Aug 16, 2017 at 4:19
  • I've added the controller code // unable to add the VF Page code
    – NCSS
    Commented Aug 16, 2017 at 4:45
  • Can u elaborate more this statement " Count of B // 10 ==== ID of A //a1 ====== ID of B // b1 (first ID if B)"
    – NITHESH K
    Commented Aug 16, 2017 at 5:07
  • Here Account is one object and it has 2 records Praveen1 & Praveen 2 The other object Consent has 10 records. 5 related to Praveen1 and the other 5 to Praveen2. The foutput should be like <<--Count - 5 ; Account ID - Praveen1 (accid) ; and Oldest Consent ID - AXYZ or first recordID of Consent related to Praveen1.
    – NCSS
    Commented Aug 16, 2017 at 5:16
  • Hi @satya , The SOQL "SELECT Count(Id)ids,Account__r.Id accids FROM Consent__c where CreatedDate >=:startDate AND LastModifiedDate <=:EndDate GROUP BY Account__r.Id" is correct according to your requirement. what you still missing in that and your said that "Unable to add Visual Force Page Code" , Which code ?
    – NITHESH K
    Commented Aug 16, 2017 at 6:50

1 Answer 1

0

Issue resolved by making modifications as suggested above

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .