+ Start a Discussion

Aggregate Query


 when i am making a group by Formula field in soql i am hitting this error can any one help to to resolve out.



Query =[select id,sum(a__c) from account group by OwnerId,Formulafield__c];


System.UnexpectedException: field 'Product_Family__c' can not be grouped in a query call


Formula fiels are not groupable, to easily know which fields are groupable for account, you can use the following code on developer console and look at raw log for variable assignment.


Boolean isGroupable = Account.Formulafield__c.getDescribe().groupable;


10:29:02.039 (39683000)|SYSTEM_METHOD_EXIT|[16]|Schema.DescribeFieldResult.isGroupable()
10:29:02.039 (39713000)|VARIABLE_ASSIGNMENT|[16]|isGroupable|true