5

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: Overige

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?

1
  • That looks like a bug to me - I'd file a case with Salesforce Support ...
    – user735
    Commented Jan 19, 2015 at 23:26

1 Answer 1

3

SELECT toLabel(Equipment__r.technical_Platform__c) aliasTECPROB FROM Maintenance_Schedule__c GROUP BY Equipment__r.technical_Platform__c

Use Alias it will work out

1
  • Really strange but indeed this is working.. Additionally, the results don't show at all if I run the query in Developer Console Query Editor. However if I run in Execute Anonymous they are displayed fine (grouped and translated) in the debug logs. Commented Jul 10, 2018 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .