I'm doing this query:
SELECT ID, Name, Email_Domain__c FROM Contact GROUP BY Email_Domain__c
And I'm getting this error
MALFORMED_QUERY: GROUP BY Email_Domain__c ^ ERROR at Row:5:Column:12
field 'Email_Domain__c' can not be grouped in a query call
Is there a way form to
GROUP BY a custom field?
Pretty much what I want to do is in one call, get the domains for all the emails from the Contact object.
When I check this field in workbench, it has these 2 properties
calculatedFormula: RIGHT(Email,((LEN(Email)-(FIND("@",Email))))) groupable: false
Yes it's possible to group by custom fields in general, but not all field types are groupable.
The docs aren't particularly helpful from what I can see, and just tell you a field is groupable if it's describe field result has a groupable value of true.
IFIRC, you can group by pretty much anything, except DateTime, Long Text Areas, and Formulas, but unfortunately I can't seem to find any explicit documentation of this.
If you want to group by a formula field you can get by with by having creating a copy of the field and having workflow populate it, e.g. whenever your email domain field changes, do a field update that puts the value into the email domain (text) field. You can then use that to group.