Loading

Understanding Picklist Value Labels and API Names in Salesforce

Date de publication: Jan 24, 2025
Description

When querying Salesforce objects, users may notice that picklist values differ across environments. This can occur due to differences in how records are created:

  • UI Entry: When records are created through the UI, the picklist label is displayed in the record. However, the label is mapped to its corresponding API name in the backend.

  • Backend or Bulk Data Load: When records are inserted programmatically or via bulk import, the API name of the picklist value is used directly. As a result, querying the data will return the API name.

For example:

  • Picklist Label: "Life Assured"

  • Picklist API Name: "Life_Assured"

When you run a SOQL query like the one below:     SELECT Id, PicklistField FROM Object

The query result will return the API name (e.g., "Life_Assured") instead of the label "Life Assured". This is because Salesforce stores and retrieves the picklist values using the API name in the database, while the label is only used for display purposes in the UI.


This behavior ensures consistency across Salesforce processes, as picklist API names are used for metadata-level operations, integrations, and automations.

Résolution

Below are key considerations to address discrepancies and maintain data integrity:

  • The picklist label is displayed in the UI, offering user-friendly readability, while the API name is used internally for processing, metadata operations, and integrations.
  • API names should be carefully chosen, especially avoiding special characters like "&," as these may cause issues in external systems.
  • Discrepancies may occur when records are created via different methods, such as through the UI versus bulk imports.
  • Query results will always return the API name, which is the stored value in Salesforce's backend. The label is used solely for display purposes.
  • Consistent data entry methods across environments can prevent variations in picklist values.
  • Altering API names after they are in use can disrupt automations, formulas, and integrations.
  • Queries are dependent on API names, ensuring uniformity in the database regardless of the label displayed in the UI.

By following these considerations, users can align processes and minimize inconsistencies between environments.

Numéro d’article de la base de connaissances

004205234

 
Chargement
Salesforce Help | Article