[SalesForce] Compile Error: Invalid Type

I am working towards getting my controller to pass queries into a visualforce gauge component. The first part works in that I can make a query convert to an integer and display on the chart. I want to make a query to set the maximum value for the gauge.

I have this code but I get an error invalid type on the List max line. What am I doing wrong it looks exactly like the first part…

public with sharing class ISOGaugeController2b {

public List<gaugeData> getData() {
//          Integer actual = 0;
//          Integer TotalAmount = 0;
//          Integer thisMonth = date.Today().month();

        AggregateResult Actuals = [select sum(amount__c) sum 
                                FROM Actuals__c 
                                Where amount__c != null 
                                AND ISO_Goal__r.OwnerId = :UserInfo.getUserId()];

        List<gaugeData> data = new List<gaugeData>();
        data.add(new gaugeData('Actual', Integer.valueof(actuals.get('sum'))));
        return data;
    }
// Wrapper class
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;
    }
}        

public List<maxData> getMax(){

        Double maximum = [select Goal__c 
                        FROM ISO_Goal__c 
                        Where Goal__c != null 
                        AND OwnerId = :UserInfo.getUserId()];

    List<maxData> max = new List<maxData>();
    max.add(new maxData('Maximum', Integer.valueof(maximum.get(Goal__c))));
    return max;
}
}

Best Answer

Your comment states:

I just want to return the one record that should match the query and display the currency field goal__c

Your method:

public List<maxData> getMax(){

    Double maximum = [select Goal__c 
                    FROM ISO_Goal__c 
                    Where Goal__c != null 
                    AND OwnerId = :UserInfo.getUserId()];

List<maxData> max = new List<maxData>();
max.add(new maxData('Maximum', Integer.valueof(maximum.get(Goal__c))));
return max;

}

should be (to return just one value) - assuming, as per your comment, that one record will always exist (otherwise, extend to include error handling)

public List<maxData> getMax(){

        return new List<maxData> {[select Goal__c 
                        FROM ISO_Goal__c 
                        Where Goal__c != null 
                        AND OwnerId = :UserInfo.getUserId()][0].iso_goal__c};
}
Related Topic