I have seven different recordtypes, but it seems that the first "for" (FOR (RecordType RType : RTypeList) loop run just once. The debug log show that the sql find 7 rows.
09:22:47.089 (89771210)|SOQL_EXECUTE_BEGIN|[11]|Aggregations:0|SELECT Id, Name FROM RecordType WHERE SobjectType = 'Opportunity'
09:22:47.124 (124132161)|SOQL_EXECUTE_END|[11]|Rows:7
Public Class VTPTeam3_class {
Public Summary[] Summaries {
get;
set;
}
Public VTPTeam3_class() {
}
Public void getInformation() {
List < RecordType > RTypeList = [SELECT Id, Name FROM RecordType WHERE SobjectType = 'Opportunity'];
FOR(RecordType RType: RTypeList) {
AggregateResult[] Results = [SELECT Account.Owner.Name accOwner, RecordType.Name oppProduct, SUM(Amount) PlanValue FROM Opportunity WHERE RecordTypeId = : RType.Id GROUP BY Account.Owner.Name, RecordType.Name];
Summaries = new List < Summary > ();
FOR(AggregateResult ar: Results) {
Summaries.ADD(new Summary(ar));
}
}
}
Public Class Summary {
Public String Ownername {
get;
set;
}
Public String Productname {
get;
set;
}
Public Double Value {
get;
set;
}
Public Summary(AggregateResult ar) {
Ownername = (String) ar.get('accOwner');
Productname = (String) ar.get('oppProduct');
Value = (Double) ar.get('PlanValue');
}
}
}