9

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?

5
  • 2
    You can find the name of any field the same way. Look at the object configuration in the 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?
    – Adrian Larson
    Commented Feb 14, 2017 at 20:16
  • Are you referencing this feature? - I don't think it's documented somewhere, or even possible as of now. You better to ask this in Global, Restricted Custom Picklists group
    – o-lexi
    Commented Feb 14, 2017 at 20:56
  • Moving this to an answer instead
    – Charles T
    Commented Feb 15, 2017 at 4:52
  • @Oleksiy, Yes I am referring to this feature. I want to refer to the picklist value API name in a Workflow formula, instead of referring to the label like I used to do before spring '17
    – Dedo
    Commented Feb 15, 2017 at 5:02
  • 1
    See below. There is no such thing as referring to the label in a formula. It'll always be the API name.
    – Charles T
    Commented Feb 15, 2017 at 5:03

1 Answer 1

14

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

1
  • Minor typo in explanation. <apex:outputField> will display translation - <apex:outputText> (as originally written) will not. Commented Jul 20, 2017 at 8:49

You must log in to answer this question.

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