Here is my code. I'm trying to read Picklist Values via code, but I also intend to find out all Inactive Values on the field as well, but those values are not getting called in below code:
list<SelectOption> picklistItems = new list<SelectOption>();
map<String, Schema.SObjectField> fMap = Schema.Task.getSObjectType().getDescribe().fields.getMap();
string fName = 'Status';
if (fMap.get(fName) != null) {
Schema.DescribeFieldResult FR = fMap.get(fName).getDescribe();
if (FR.isAccessible()) {
if (FR.getType() == Schema.DisplayType.Picklist) {
for (Schema.PicklistEntry ple : FR.getPicklistValues()) {
picklistItems.add( new SelectOption(ple.getLabel(), ple.getValue()) );
}
}
}
}
Is there a way I can retrieve full picklist values via some code?
NOTE: The InActive values in my case here are the values which user has created records with, from APEX, the values are his own custom ones coming from code. I mean, you know we can save any custom picklist value from Apex, even though the value is not part of Picklist definition from package developer, but Salesforce allows user to be able to save records without any issues, and the value now becomes part of picklist but shown as Inactive values when we open the field in object explorer.
isActive()
method, that cannot be used?InActive
values were created by customer and are not retrieved by describe call, thus cannot filter byisActive()
.