I created an apex method that dynamically gets and displays all the values of a picklist field as options based on a criteria (criteria 1)
Values: Value1, Value2
But there are other two requirements which I am having some difficulty solving with:
when criteria 2 is achieved, the picklist must only display Value 1 as the option
when criteria 3 is achieved, the picklist must only display Value 2 as the option
How can I do this?
Meanwhile, here's the method I created for criteria 1:
public List<SelectOption> getValues()
{
List<SelectOption> options = new List<SelectOption>();
Schema.DescribeFieldResult fieldResult =
Object1__c.Picklist_Field__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}