Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

How to Retrieve Translated Picklist Values in Apex Based on the Language of the Logged in User

公開日: Aug 25, 2025
説明

When working with multilingual Salesforce orgs, it's often necessary to display picklist values in the user's preferred language. This article explains how to retrieve translated picklist values in Apex using Salesforce native capabilities.

解決策

Salesforce provides an efficient and dynamic way to retrieve translated picklist values using Apex. The picklist values are automatically translated based on the language preference of the Logged-in User, assuming translations have been configured in the Translation Workbench.

Ensure that translations for picklist values are configured in SetupTranslation Workbench.

The Logged-in User's language defined in their User setting must have translations defined for the desired field.

 

Step 1. Get the Logged-in User’s language

String userLanguage = UserInfo.getLanguage();

 

Step 2. Retrieve the translated picklist values dynamically

Here's an example using the Industry field from the Account object

Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
List<Schema.PicklistEntry> picklistValues = fieldResult.getPicklistValues();

for (Schema.PicklistEntry entry : picklistValues) {
    System.debug('API Name: ' + entry.getValue());
    System.debug('Translated Value: ' + entry.getLabel());
}

 

Notes

  1. entry.getValue() returns the API name, e.g. Technology
  2. entry.getLabel() automatically returns the translated Label according to the User’s language setting

__________________________________________________________________________

Written by: Jonathan Fox | Forum Ambassador
Head of Salesforce Architecture, Jonathan Fox is a 32x Certified Salesforce Architect, Agentblazer Legend and Golden Hoodie Recipient.

Submissions reflect only the opinions of the user who made available the Submission and not the opinions of Salesforce, regardless of whether the user is affiliated with Salesforce, and may contain or constitute products, services, information, data, content and other materials made available by or on behalf of third parties ("Third Party Materials).  Salesforce neither controls nor endorses, nor is Salesforce responsible for, any Third  Party Materials, including their accuracy, validity, timeliness, completeness, reliability, integrity, quality, legality,  usefulness or safety, or any applicable intellectual property rights. Any Submissions made available through any message board or forum in response to posted questions, or that otherwise purports to answer any questions, including any questions about Salesforce or Programs, are made available for your general knowledge only and should never be relied upon as answers to your specific questions (even if an answer is marked as a “best” answer or with any similar qualifications). You should always contact Salesforce support for answers to your specific questions. Salesforce has no control over Submissions, and is not responsible for any use or misuse (including any distribution) by any third party of Submissions.

If you have questions, tap into the wisdom of our entire Trailblazer Community here: https://trailhead.salesforce.com/trailblazer-community/feed

ナレッジ記事番号

005132333

 
読み込み中
Salesforce Help | Article