In Spring '17 I am trying to use picklist value API name in a formula. How can I access a picklist value API name in a formula like ISPICKVAL?
1 Answer
Formula fields already see the API name and only the API name (yes, even TEXT(fieldName)
gets you the API name, not the label). There is currently no way to fetch the label instead from a formula field. On the plus side, this means that existing formulas will not break if you re-label the picklist values in the future, as long as you keep the API name fixed.
In general - picklist values in unilingual Salesforce orgs are now behaving similarly to how they behave in Translation Workbench for multilingual orgs. The API name is the authoritative value of each picklist option. It's what you see by default when you obtain it in code, and it's what you must set it to when assigning a value. The label is now a translation that is only used in display contexts.
In SOQL, querying a picklist gets you the API name. Querying using toLabel(field name)
gets you the translation.
In Visualforce, two things that used to be the same for unilingual orgs no longer are (but these have been different in multilingual orgs all along):
{!Contact.LeadSource}
<-- this will display the API name.
<apex:outputField value="{!Contact.LeadSource}" />
<-- this will display the translation
-
Minor typo in explanation. <apex:outputField> will display translation - <apex:outputText> (as originally written) will not. Commented Jul 20, 2017 at 8:49
Setup
menu, or use describes. Is it a standard or custom object? Also why not just use the formula builder functionality that injects the field for you?