function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RathishRathish 

Getting picklist values in different language

Hi,
 
Translation workbench is enabled for our organization. And one of the picklist valus are converted to a native language Chinese.
 
Through code, I would like to get the picklist values in chinese.
 
Can you help me on this?
 
Regards,
 
Rathish
SuperfellSuperfell
You can only get picklist (and other) labels in the language for the active user. i.e. if the user that makes the API call is setup for the chinese language, the labels returned by the describeSObject call will be in chinese.
RathishRathish

Hi Simon,

Thanks for the reply.

Through the applicatrion a default user has been used to get the values from SFDC and the language has been set as English for that user in SFDC.

But when a customer from China accessing our application should get the values in Chinese from SFDC. The chinese values for different picklists are stored in Translation workbench.

Is that possible to get these values for a chinese customer?

Regards,

Rathish.

SuperfellSuperfell
Not without having a user account with their language set to chinese.
ChrisGountanisChrisGountanis
How do you get picklist values period? For an easy example Case > Origin is a picklist with mutiple values. How do you get that in .NET for use loop to combobox (drop down). Please
SuperfellSuperfell
call describeSObject("Case"), the result has a fields property that is an array, loop through that until you get to the field named Origin, look at the PickListValues property of that field. see the API docs for more details.
ChrisGountanisChrisGountanis
OK that is what I did. Was just hoping for a more of a direct hit for speed.
RathishRathish

Please find the way I did it.

public webrefSForce.PicklistEntry[] GetIndustryPicklist()//V1.2

{

try

{

webrefSForce.PicklistEntry[] objPick = null;//Declaring PicklistEntry object, which will hold all the regions

webrefSForce.DescribeSObjectResult objDescribeSObjectResult = cobjBinding.describeSObject("Lead");

foreach (webrefSForce.Field objField in objDescribeSObjectResult.fields)

{

if (objField.type == webrefSForce.fieldType.picklist && objField.name == "Industry") // Is this a picklist and is the field name Type—

{

objPick = objField.picklistValues;

}

}

return objPick;

}

catch (Exception ex)

{

throw ex;

}

}

ChrisGountanisChrisGountanis
Thanks guys.
Makary BortnowskiMakary Bortnowski

There is one, although dirty way, to do it. You have to change the current user's language for purpose of desired code execution:

 

User currentUser = [SELECT Id, LanguageLocaleKey FROM User WHERE Id = :UserInfo.getUserId()];
currentUser.LanguageLocaleKey = 'da';
update currentUser;

// your code

currentUser.LanguageLocaleKey = 'en_US';
update currentUser;