0

below code is fetching all the picklist values of status field (case object). i want only active picklist values how it is possible.

   caseStatuslist = new List<SelectOption>();
    Schema.DescribeFieldResult fieldResult =  Case.Status.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

   for( Schema.PicklistEntry f : ple) {
      caseStatuslist.add(new SelectOption(f.getLabel(), f.getValue()));
   }

1 Answer 1

4

You can use the isActive() function on the PicklistEntry class.

For example, in your for loop you can check each iteration to see if it's active:

for(Schema.PicklistEntry f : ple) {
  if (f.isActive()) {
    caseStatuslist.add(new SelectOption(f.getLabel(), f.getValue()));
  }
}

As mentioned in the docs, this function returns a Boolean that:

Returns true if this item must be displayed in the drop-down list for the picklist field in the user interface, false otherwise.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .