Skip to main content
A few releases ago a change was introduced so that picklists API names could be different from their corresponding values. I would like to know what is the best practice. In what cases is advisable to have API names different from their values? I'm told that to work in Apex (which I only vaguely know) it's better always numbers in the API names for their corresponding text values e.g.

 

Values        API Name

 

Active          1

 

Inactive        2

 

Cancelled    3

 

I'm also told that it might be useful for integration with other systems. However, when API Names and Values differ this causes some inconveniences elsewhere (mass updates, certain reporting, etc.)

 

I've never seen a proper explanation of the best practice and when it's recommended to have API Names different from values in picklists. Does anybody have recommendations? Thanks.
4 个回答
  1. 2019年11月20日 11:10
    If somebody had told me this, I would have found it very stupid because that seems very difficult to manage in my head at least. 

     

    I think you should have the person 'Why' when he/she suggested you this.

     

    Anyways, what I have seen so far in my experience, a lot depends on the implementation structure. But I really cannot think where we would need this value to number mapping. But I can think of a use case when you would need a different API name then label. 

     

    Say you have a value 'A & B', then you have an external system using this value, and the character '&' is causing a problem(it mostly does), when the code is reading this picklist value. So in this case, you would keep the label as it is and use a different but similar value for the api name. 

     

    Makes sense?

     

    Anyway, picklist API values are not be messed with. Becuase a lot of formula, automation rules, integrations etc are dependent on them.

     

    Additional info:

     

    https://developer.salesforce.com/blogs/developer-relations/2017/01/keeping-picklist-integrations-safe-using-api-names.html

     

    https://help.salesforce.com/articleView?id=fields_picklist_protect.htm&type=5 (https://help.salesforce.com/articleView?id=fields_picklist_protect.htm&type=5

     

     
0/9000