8

I have am email body I'm generating in APEX and I want it to include the translated value of a picklist. How can I get the translated value in APEX?

10

You can use a SOQL function toLabel() to get translated picklist values:

SELECT toLabel(your_field__c) FROM YourObject__c 

Here is the official documentation:

A client application can have results from a query returned that are translated into the user’s language, using toLabel()

| improve this answer | |
  • mind adding a documentation reference or explaining how this function works ? – Samuel De Rycke Nov 4 '13 at 15:10
  • 1
    thanx @mast0r for adding the documentation link and for the edit :) – ManSpan Nov 4 '13 at 15:18
  • 2
    Thanks, but this is not ideal for me, I have the records already (getting them from the trigger). I prefer not to query again. I hoped there is something like 'getTranslatedValue()' or something like quering the translated values themselves – Dedo Nov 4 '13 at 15:35
  • How about using email templates ? then you don't need to worry about translations SForce does it for you – ManSpan Nov 4 '13 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.