You need to sign in to do that
Don't have an account?
priya burghate
While creating custom chart showing 'Invalid field Owner.name for AggregateResult' error has occured
I want to create pie chart account for owner having there accounts but it shows Invalid field 'Owner.name' error in aggregateResult..
Can anyone plz help to sort out?
public with sharing class Graph1
{
public List<PieWedgeData> getPieData1() {
List<PieWedgeData> data = new List<PieWedgeData>();
List<AggregateResult> groupedResults = [SELECT Owner.name, count(name)cnt
FROM Account
GROUP BY Owner.name];
for (AggregateResult ar : groupedResults) {
data.add(new PieWedgeData(String.valueOf(ar.get('Owner.name')),Integer.valueOf(ar.get('cnt'))));
}
return data;
}
// Wrapper class
public class PieWedgeData {
public String name { get; set; }
public Integer cnt { get; set; }
public PieWedgeData(String name, Integer data) {
this.name = name;
this.cnt = cnt;
}
}
}
Can anyone plz help to sort out?
public with sharing class Graph1
{
public List<PieWedgeData> getPieData1() {
List<PieWedgeData> data = new List<PieWedgeData>();
List<AggregateResult> groupedResults = [SELECT Owner.name, count(name)cnt
FROM Account
GROUP BY Owner.name];
for (AggregateResult ar : groupedResults) {
data.add(new PieWedgeData(String.valueOf(ar.get('Owner.name')),Integer.valueOf(ar.get('cnt'))));
}
return data;
}
// Wrapper class
public class PieWedgeData {
public String name { get; set; }
public Integer cnt { get; set; }
public PieWedgeData(String name, Integer data) {
this.name = name;
this.cnt = cnt;
}
}
}
in the place of owner.name give name
data.add(new PieWedgeData(String.valueOf(ar.get('name')),Integer.valueOf(ar.get('cnt'))));
try it
All Answers
in the place of owner.name give name
data.add(new PieWedgeData(String.valueOf(ar.get('name')),Integer.valueOf(ar.get('cnt'))));
try it
It works out....
thank you so much...:-)