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