I'm using Partner API to describe salesforce schema. For some reason, in picklist fields I only see the active values (although there's a field "getActive()")

Is this a limitation or am I doing something wrong? how can I get the Inactive picklist values?

My code is along the lines of:

    obj = partnerConnection.describeSObject("Lead");
    for (Field f : obj.fields) {

       if (FieldType.picklist.equals(f.getType()) || FieldType.multipicklist.equals(f.getType())) {
         for (PicklistEntry e : f.getPicklistValues())  {
         if (e.getActive()) {
            // This is OK       
            // This part is not reached, seems Inactive values are not returned ...

I believe this to be a current limitation of the API for picklist fields.

I tried as well to get field metadata for a deactivated picklist value. It didn't come back, even though there is an active property.

It appears the same problem exists in the REST API with the /describe resource or a tooling API query against FieldDefinition - Obtain the complete list of Picklist values via REST API (both active and inactive)

The limitation even goes to the Apex class. E.g. the following won't return inactive picklist values:

Schema.DescribeFieldResult F = Account.Rating.getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();

The Metadata API used to expose a Picklist Metadata type, but for v38.0 and later it switched to ValueSet.

I think most of the problems stem from Picklist in the older Metadata API not exposing a IsActive property. However, CustomValue, that is used from v38.0 onwards does have a isActive.

Update: I thought that the new Metadata API StandardValueSet would have exposed the isActive field. However, with the following Metadata API package it doesn't come back.

package.xml for the Account.Rating picklist.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

Response \standardValueSets\AccountRating.standardValueSet

<?xml version="1.0" encoding="UTF-8"?>
<StandardValueSet xmlns="http://soap.sforce.com/2006/04/metadata">

Deactived Picklist Value

| improve this answer | |
  • Thank you, this supports what I believe as well. Is there some other API which does expose this? – Yossi Vainshtein Dec 1 '16 at 9:36
  • @YossiVainshtein Not that I can find. All the API's seem to exclude inactive picklist values. – Daniel Ballinger Dec 1 '16 at 23:47

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.