5

This Salesforce org includes English and Italian versions of field labels and picklist value labels. This works find within the UI, and for most purposes. However, we have a custom CSV upload page with a validation step that makes sure the values in picklist fields match the standard values, and the picklist values that are returned by the Apex describe command are in the current User's language. For the sake of standardization, we want the CSVs to always be in English, even if the uploading User is Italian.

This is the code I'm using to retrieve the picklist values, which returns it in the current User's language:

Map<String, Schema.SobjectField> allfieldsmap = Schema.SObjectType.Contact.fields.getMap();
Schema.DescribeFieldResult describedField = allfieldsmap.get('Permanent_Country__c').getDescribe();

set<String> picklistvalues = new set<String>();
for (Schema.Picklistentry entry : describedField.getPicklistValues())
{
    picklistvalues.add(entry.label);
}

For an Italian user this gives me a list of countries in Italian (Italia, Messico, etc) instead of the English names, which means that the CSV being uploaded would need to use the Italian versions.

  • How can I get a list of picklist values in English?
  • How can I map the English version of a picklist value to the value in the user's language and successfully update the Permanent_Country__c field?
2
  • Does entry.value return the English value? Commented Mar 29, 2013 at 21:49
  • How about using country codes, is that an option ?
    – altius_rup
    Commented Oct 10, 2013 at 21:07

1 Answer 1

2

You only have to use the getValue method instead getLabel.

change this line :

  picklistvalues.add(entry.label);

by this one:

  picklistvalues.add(entry.getValue());

getValue()

Returns the value of this item in the picklist.

getLabel()

Returns the display name of this item in the picklist.

Sum-up: label returns the translated value and value the defined value in the field.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .