4

Used this code to get PicklistEnry list from field and get Label from it:

DescribeFieldResult res = Organization.getSObjectType().getDescribe().fields.getMap().get('OrganizationType').getDescribe();

List<PicklistEntry> entries = res.getPicklistValues();
for (PicklistEntry entry : entries) {
    System.debug(entry.getValue() + ' : ' + entry.getLabel());
}

It worked yesterday, but today I'm getting null for labels:

05:56:41.13 (29155386)|USER_DEBUG|[5]|DEBUG|Team Edition : null
05:56:41.13 (29290993)|USER_DEBUG|[5]|DEBUG|Professional Edition : null
05:56:41.13 (29398823)|USER_DEBUG|[5]|DEBUG|Enterprise Edition : null
05:56:41.13 (29535199)|USER_DEBUG|[5]|DEBUG|Developer Edition : null
05:56:41.13 (29681282)|USER_DEBUG|[5]|DEBUG|Personal Edition : null
05:56:41.13 (29809578)|USER_DEBUG|[5]|DEBUG|Unlimited Edition : null
05:56:41.13 (29944321)|USER_DEBUG|[5]|DEBUG|Contact Manager Edition : null
05:56:41.13 (30078120)|USER_DEBUG|[5]|DEBUG|Base Edition : null

The question:

Was there any update that SF released without notification? I have checked OrganizationType from Organization standard object on several orgs, but result is the same.

UPDATE:

I have logged a case (28390515) with SF Support for this issue, will update question soon.

  • I don't think this is a problem with PicklistEntry labels as such, but only with OrganizationType field on Organization object. Looking up the picklist entry details for this field in Salesforce Inspector or Workbench, the label is actually empty. I've never tried to query the label for the picklistentries of this particular field before. May be this is default set-up/ behaviour of this particular field. Fetching the labels on all other (most) picklist field entries is working fine. – arut Nov 30 '20 at 15:04
  • 1
    @arut This is actually the most interesting moment, as for the 29th of November it worked with this field, too :) – Mariia Illarionova Nov 30 '20 at 15:35
3

This is almost certainly a bug. Yes, Salesforce does receive occasional mid-cycle patches, which are usually documented (see this question for more info). I would recommend contacting Support to log a bug.

  • 1
    I have logged a case (28390515) with SF Support for this issue, will update question soon. – Mariia Illarionova Dec 1 '20 at 8:26
1

Out of curiosity I also tried to find any other standard picklists with nulls in labels of entries. Apparently, there is a lot of them. Code to try:

for (SObjectType obj : Schema.getGlobalDescribe().values()) {
    DescribeSObjectResult objectResult = obj.getDescribe();
    if (objectResult.isCustom()) continue;
    for (SObjectField field : obj.getDescribe().fields.getMap().values()) {
        DescribeFieldResult fieldResult = field.getDescribe();
        if (fieldResult.isCustom()) continue;
        if (fieldResult.getType() == DisplayType.PICKLIST || fieldResult.getType() == DisplayType.MULTIPICKLIST) {
            List<PicklistEntry> entries = fieldResult.getPicklistValues();
            if (entries != null && entries.size() > 0 && entries[0].getLabel() == null) {
                System.debug(objectResult.getName() + ' : ' + fieldResult.getName());
            }
        }
    }
}

Also I have a response from Salesforce Support:

Based on product team findings label values never existed for OrganizationType picklist as this picklist is only used for internal user or integration purposes.

...

using getlabel function for picklist will be a new feature request for salesforce.

  • Doesn't the statement Based on product team findings label values never existed for OrganizationType picklist contradict your previous observations about this picklist field? – arut Dec 2 '20 at 19:06
  • 1
    @arut Yes, it does, however, it worked for us and I have told support about it, they said it's strange and it shouldn't have worked. But we were calling this from API and label began failing in php __construct method, so there might have been some chenges in php, but I doubt it more than in SF. Anyway, I'm glad that it will be working in next releases. – Mariia Illarionova Dec 2 '20 at 19:09
  • it's strange and ... is not something I would want to hear from Salesforce support team :). Anyways, thanks for the update. – arut Dec 2 '20 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.