I'm trying to get the active and inactive values, especially the inactive ones, from a picklist to activate them via code. The problem is that I can only get the active values.

List<String> pickListValuesActive   = new List<String>();
List<String> pickListValuesInactive = new List<String>();

Schema.DescribeFieldResult fieldResult = ObjectApiName.PicklistApiName.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for(Schema.PicklistEntry pickListVal : ple) {
   if(pickListVal.isActive()) {
   } else {

I thought about using a trigger after inserting values to make a treatment, but from what I researched it won't work because these picklist values are metadata.

Please, does anyone know if is there any way I can get the inactive values from a picklist and activate them via code?

  • Do you mean that you want to find active and inactive picklist values from picklist field? – Samir Mar 10 at 13:09
  • Exactly, I want to take both active and inactive values. Mainly inactive ones, because I will activate them via code. – dsd Mar 10 at 13:37
  • How are you going to activate them by code? - Metadata API? – cropredy Mar 10 at 17:23
  • I thought I could set the isActive() property to the value of true, but I also don't know if it is possible, because my initial idea is to visualize this inactive data to see what are the possible treatments to be done. – dsd Mar 10 at 18:17
  • 1
    Please edit your post to change "objects" to "values". When you say "objects" it is confusing. – David Cheng Mar 10 at 18:20

Your Answer

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

Browse other questions tagged or ask your own question.