Schema.DescribeFieldResult should provide method to get inactive picklist values - Ideas - Salesforce Trailblazer Community
Trailblazer Community

All Ideas

Idea Details

Post an Idea
470  Points
Open
Idea has been posted. Give it an upvote or downvote.

Schema.DescribeFieldResult should provide method to get inactive picklist values

Developer Tools

Schema.DescribeFieldResult class provides a method called getPicklistValues() which returns a list of active values in the picklist field. This class should also provide a method called getInactivePicklistValues() which will return a list of all the inactive values in this picklist as inactive picklist values can also be assigned to records of that object. So if we want to find out using Apex code which inactive picklist values are in use (are assigned in any record of that object), then we can do so using this new method if it is provided.

Existing code of getPicklistValues() method :-
// Account_classification__c is a picklist field on Account standard object
Schema.DescribeFieldResult fieldResult = Account.Account_classification__c.getDescribe();

// This will return the active picklist values only
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for(Schema.PicklistEntry pickListVal : ple)
{
    System.debug(LoggingLevel.INFO, '#### picklist label is ' + pickListVal.getLabel());
    System.debug(LoggingLevel.INFO, '#### picklist value is ' + pickListVal.getValue());

    // Always only "true" will get printed for isActive checking
    System.debug(LoggingLevel.INFO, '#### picklist isActive is ' + pickListVal.isActive());
}

Merge Idea · Flag

  • Upvotes
  • Downvotes

Ideas

Apps

from AppExchange

Questions

No results found.

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



 

 

Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


 

Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.