You need to sign in to do that
Don't have an account?
hal9001
aggregate results cannot be used in a batch query
I'm trying to save the following custom list controller, but I' getting the error: aggregate results cannot be used in a batch query
public class summaryListCon { // ApexPages.StandardSetController must be instantiated // for standard list controllers public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator( [SELECT Trans__c.Transaction__r.Equipment__r.Name Equipment ,Trans__c.Location__r.Location_Type__r.Name LocType ,Trans__c.Location__r.Account__r.Name Account ,Trans__c.Location__r.Name Location ,SUM(Qty__c) Qty,Sum(Product_Days__c) Product_Days from Trans__c GROUP BY Trans__c.Transaction__r.Equipment__r.Name ,Trans__c.Location__r.Location_Type__r.Name ,Trans__c.Location__r.Account__r.Name ,Trans__c.Location__r.Name ] )); } return setCon; } set; } // Initialize setCon and return a list of records public List<SObject> getSummary() { return (List<SObject>) setCon.getRecords(); } }
How can I use aggregate results on a VisualForce page?
Thanks!
Here is the solution that worked for me:
the controller:
and the page:
All Answers
OK, so I need to use something like this:
I think I'm making progress. Now I'm getting the error:
Error: Invalid field Equipment for SObject AggregateResult
when I try to save this page:
and here is the controller:
I've tried referring to the Equipment field using the full name instead of the alias, but I get similar errors.
Here is the solution that worked for me:
the controller:
and the page: