I am trying to populate a picklist with my salesforce orgs displayed languages (viewable through setup > Company Settings> Language Settings).
There is a way to access all available languages (specifically User LanguageLocaleKeys):
Schema.DescribeFieldResult fieldResult = User.LanguageLocaleKey.getDescribe(); List<Schema.PicklistEntry> picklistValues = fieldResult.getPicklistValues();
However I don’t want to display all LanguageLocaleKeys as my org only supports the languages we have set as displayed languages. Additionally, when some users register with the picklist with all available languages and pick a language that is not in the “displayed languages lists”, their language locale key shows as a number in their User detail page in salesforce instead of their language (for example nl_BE shows as 22).
Is there any way to filter this list? Or only retrieve the displayed languages?
Thanks!
Answer
Based on the documentation of the User
object, if you remove a language from the Displayed Languages
, the corresponding PicklistEntry
becomes inactive. Based on my experimentation, this appears to hold true.
In API version 47.0 and later, when using the
DescribeSObjectResult
API to returnPicklistEntry
values from this picklist, theactive
value indicates whether the language is in the user’s Displayed Languages (true
) or the user’s Available Languages (false
). All other languages aren’t in the returned active value array.
Attribution
Source : Link , Question Author : Sarah Ganci , Answer Author : Adrian Larson