+ Start a Discussion
Admin BlueJackAppsAdmin BlueJackApps 

getPickListValues() doesn't return translated label in Sandbox where I deploy the managed package for testing

I have code similar to this:
picklistMap = new Map<String, String>();
List<Schema.PicklistEntry> picklistValues = CustomMetadata__mdt.Field__c.getDescribe().getPicklistValues();
for (Schema.PicklistEntry pe: picklistValues) {
    picklistMap.put(pe.getValue(), pe.getLabel());
It works great in my developer org, where I'm creating the managed-beta package for testing. If I switch the user language to Portuguese, for instance, I have the translations included in the package and getLabel returns the translated string for the picklists.

But when I install the managed-beta package in my developer sandbox, all the other translations work - except the getLabel() call in the code above. No matter what I do I get the English label.

I see no way to include translations in the managed-beta package other than "translations", and I included all of it.

What am I doing wrong?
Admin BlueJackAppsAdmin BlueJackApps
A few extra data points:
  1. The reason I'm using Apex to get the picklist values for the custom metadata type fields is that custom metadata types cannot be edited in a VF page. They are read-only. I need to provide a better user-experience to my clients, including only presenting a subset of the custom metadata type fields. I have my apex code properly updating custom metadata types, and it all works - but the translation of the fields.
  2. The only reason I can find for the custom metadata field values not being translated is if they are not being included in the package. I have no way to control what is included as far as translations to the managed package - the package builder decides that on its own based on, I understand, whatever is being used in VF pages.
So I tried to add the custom metadata type field I'm looking for in Apex to the VF page, imagining that would trigger the package manager to include it in the translation set. Like such:
<apex:inputField value="{!CustomMetadataInstance.SomeField__c}"/>
In the org where I'm developing, the field does show when the VF page renders - read-only, as per 1 above - and it does translate appropriately if I switch languages. But when the package is deployed to another org, alas the field only displays in English.

So I think this question now is:
  • Do Custom Metadata Type field translations get included in the managed package translation sets?
Admin BlueJackAppsAdmin BlueJackApps
I should also note that the visibility of my Custom Metadata Type is PUBLIC (even though I intend to make it PRIVATE later) and when I access the Setup > Developer > Custom Metadata Types > Manage Records to see the actual OTB UI for the Custom Metadata Type record editing, it does the same thing as in my own VFP, meaning: in the org where I'm creating the package I see the properly translated picklists, but in the dev org where I deploy the managed package, while everything else (field labels, helptext, etc.) are properly translated, the picklist values do not.

I tried:
  • Removing the translations from the managed package and installing it on the dev org (all labels, helptext and picklists were in English regardless of the current user language)
  • Re-adding the translations to the managed package and installing it on the dev org (labels and helptext translated, picklists didn't)
It looks like no matter what I do, I can't get the translations for the custom metadata type picklists added to the translation set in the managed package.

So the question narrows down to:
  • Do Custom Metadata Type Picklists value translations get included in the managed package translation sets?
Admin BlueJackAppsAdmin BlueJackApps
BTW, I understand that I can create labels and use those, but that will mean that I have to maintain labels every time I have a change to the picklist values. This isn't the end of the world, but it is yet another thing to keep track of.

But I'm really just curious as to WHY I can't seem to add the picklist value translations to the managed package.
Admin BlueJackAppsAdmin BlueJackApps
Well, I think there is some sort of bug when it comes to picklist value translations for custom metadata types being included in packages.

I just created a new custom metadata type, with a new picklist field and one language translation for the picklist values. I included all of it in an unmanaged package, uploaded and installed it in the sandbox org I'm using for testing, and the translated picklist values are not displayed in the out-of-the-box custom metadata type manage records screen.

Unmanaged package with the Custom Metadata Type, Field, PIcklist and translations

I'm going to work around this by leveraging labels, but I still would like to hear from someone at Salesforce about this. Seems like something that may affect any international adopters of the Custom Metadata Type functionality.
Vishal ShelarVishal Shelar
Was this issue resolved? I am trying to get the state and country picklist for the user. I am able to the translated labels in the dev org from apex but in the sandbox, I am getting the default English one.

Admin BlueJackAppsAdmin BlueJackApps
It wasn't resolved for me. I had to work-around the problem using labels.
Vishal ShelarVishal Shelar
Can you share the workaround? did you create case with Salesforce?
Admin BlueJackAppsAdmin BlueJackApps

Never created a case with SFDC - moved on using the workaround.

The workaround was to use labels with translations and build the dropdown in my VFP using the labels instead of relying on the field values.