I am using the toLabel function in an aggregate query, but it doesn't return the translation of the picklist value.
I have changed the language of the user to Dutch and executed the following query:
SELECT toLabel(Equipment__r.technical_Platform__c) FROM Maintenance_Schedule__c GROUP BY Equipment__r.technical_Platform__c
The query returns the English value:
Other Elevator likes
When I remove the GROUP BY from the query, it returns the translated value:
SELECT toLabel(Equipment__r.technical_Platform__c) FROM Maintenance_Schedule__c
Result with the Dutch value:
I am not able to add the toLabel function in the GROUP BY, since only date aggregate functions are allowed as grouping expressions. I checked the documentation of the toLabel function, but it doesn't mention anything about grouping expressions. Documentation
I also found a topic about the same issue on the developer forums of Salesforce, but it didn't get any replies and it is from 2012. Topic
I could execute a 2nd query without the GROUP BY to get the translated values and map it to results of the results of the query with the GROUP BY, but I am wondering if there is a better solution?