You need to sign in to do that
Don't have an account?
Kris Hollen 14
Apex class for VisualForce chart
I am coding a new visualforce chart and need help with the Controller... I am new to Apex so I appologize if the fix is something basic but I am unable to figure this out. Here is my code:
public class GaugeChartController {
public String acctId {get;set;}
public GaugeChartController(ApexPages.StandardController controller){
acctId = controller.getRecord().Id;
}
public List<gaugeData> getData() {
AggregateResult SurveyResponses = [select Account__c, Count(Name), avg(Liklelihood_of_recommending_AECOM__c) npsscore
from NPS_Survey_Response__c
where Account__c =: acctId
group by Account__c];
List<gaugeData> data = new List<gaugeData>();
data.add(new gaugeData(Integer.valueOf(SurveyResponses.get('npsscore'))));
return data;
}
public class gaugeData {
public String name { get; set; }
public Integer size { get; set; }
public gaugeData(String name, Integer data) {
this.name = name;
this.size = data;
}
}
}
I need to calculate the Average of a field from a related list I have off of the Account record. I would like to either A) take this fields from the existing roll up summary field i have on the Account, OR B) Use the Aggregate function to calculate based off of the related list...
I am not sure which is easier but if anyone can help me with this I would greatly appreciate it- this would be for a gauge chart. In the above code I am getting an error stating the constructor in line 16 is not defined- Highlighted in Bold
public class GaugeChartController {
public String acctId {get;set;}
public GaugeChartController(ApexPages.StandardController controller){
acctId = controller.getRecord().Id;
}
public List<gaugeData> getData() {
AggregateResult SurveyResponses = [select Account__c, Count(Name), avg(Liklelihood_of_recommending_AECOM__c) npsscore
from NPS_Survey_Response__c
where Account__c =: acctId
group by Account__c];
List<gaugeData> data = new List<gaugeData>();
data.add(new gaugeData(Integer.valueOf(SurveyResponses.get('npsscore'))));
return data;
}
public class gaugeData {
public String name { get; set; }
public Integer size { get; set; }
public gaugeData(String name, Integer data) {
this.name = name;
this.size = data;
}
}
}
I need to calculate the Average of a field from a related list I have off of the Account record. I would like to either A) take this fields from the existing roll up summary field i have on the Account, OR B) Use the Aggregate function to calculate based off of the related list...
I am not sure which is easier but if anyone can help me with this I would greatly appreciate it- this would be for a gauge chart. In the above code I am getting an error stating the constructor in line 16 is not defined- Highlighted in Bold