You need to sign in to do that
Don't have an account?
prasanth kumar
simple aggregate program not working, please help
hi dudes, this is simple aggregate program and here i am sending the aggregate results (values) to the wrapper class, here i am getting error. please some one help, thanks in advance.
This is the error showing in developer console.
Method does not exist or incorrect signature: [aggregateExample].get(String) at line 11.
This is the error showing in developer console.
Method does not exist or incorrect signature: [aggregateExample].get(String) at line 11.
public class aggregateExample { public list<AggregateResult> result{set;get;} public list<ReportExample> reports{set;get;} public aggregateExample() { result=[select StageName,avg(amount)amt from opportunity group by StageName]; reports=new list<ReportExample>(); for(aggregateExample rs:result) { ReportExample re=new ReportExample(); re.Stagen=(string)rs.get('stagename'); re.amount=(decimal)rs.get('amt'); reports.add(re); } } public class ReportExample { public string Stagen{set;get;} public decimal amount{set;get;} } }
The problem is with the way fields are retrieved and accessed in an Aggreaget Result set. You cannot iterate an sObject list directly using aggreaget list. I have changed it and let me know if it works: