You need to sign in to do that
Don't have an account?
Raja Sharma 7
System.UnexpectedException: field 'Full_Material_Name__c' can not be grouped in a query call
When I use Full_Material_Name__c field (Type: Long Text ) then i got error "System.UnexpectedException: field 'Full_Material_Name__c' can not be grouped in a query call " for that code.
Apex Class:
Public Controller(){
AggregateResult[] results = [SELECT Full_Material_Name__c, SUM(Total_Price__c) Total, SUM(Total_Unit_Price__c) Totalu, Count(Id) Quantity FROM Order_Line_Item__c WHERE Order_ID__c =: order.Id GROUP BY Full_Material_Name__c];
Summaries = new List<Summary>();
for(AggregateResult ar : results) {
Summaries.add(new Summary(ar));
}
}
// wrapper class to hold aggregate data
public class Summary {
public Integer Quantity {get; private set; }
//public String Name {get; private set; }
public Integer Total {get; private set;}
public Integer Totalu {get; private set;}
public String FullName { get; private set; }
public Summary(AggregateResult ar) {
Quantity = (Integer) ar.get('Quantity');
// Name = (String)ar.get('Master_Material_Lookup__c');
Total = Integer.valueOf(ar.get('Total'));
Totalu = Integer.valueOf(ar.get('Totalu'));
FullName = String.valueOf(ar.get('Full_Material_Name__c'));
}
}
when i use lookup field that code working properly when i use Text field then that gives me the following error.
Apex Class:
Public Controller(){
AggregateResult[] results = [SELECT Full_Material_Name__c, SUM(Total_Price__c) Total, SUM(Total_Unit_Price__c) Totalu, Count(Id) Quantity FROM Order_Line_Item__c WHERE Order_ID__c =: order.Id GROUP BY Full_Material_Name__c];
Summaries = new List<Summary>();
for(AggregateResult ar : results) {
Summaries.add(new Summary(ar));
}
}
// wrapper class to hold aggregate data
public class Summary {
public Integer Quantity {get; private set; }
//public String Name {get; private set; }
public Integer Total {get; private set;}
public Integer Totalu {get; private set;}
public String FullName { get; private set; }
public Summary(AggregateResult ar) {
Quantity = (Integer) ar.get('Quantity');
// Name = (String)ar.get('Master_Material_Lookup__c');
Total = Integer.valueOf(ar.get('Total'));
Totalu = Integer.valueOf(ar.get('Totalu'));
FullName = String.valueOf(ar.get('Full_Material_Name__c'));
}
}
when i use lookup field that code working properly when i use Text field then that gives me the following error.
More info :
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_group_by_considerations.htm
https://salesforce.stackexchange.com/questions/5818/what-makes-a-field-not-groupable
Hope it helps you.
Thanks
Varaprasad
Thank you for the reply.
I have already worked on following links but I am not able to group by text area long field.
Thanks
Raja