1

I am new to SF technology.Here in my requirement I have one object Advertisement__c, it has a picklist named Locality__c. This pick list is used on two custom VF pages, on one page I want to use it as single select where as on page I need to use it as multiselect and I have bound this picklist using <apex:inputfield> . Please let me know whether is it possible to customize picklist in this way ?

1 Answer 1

0

This is not possible in native way. but three are multiple workarounds like: create this picklist as multiselect picklist.

  1. Now in one place display it using apex:inputfield. and another place get all value using describe and then create selectoption list and populate this field using single select.

Sample code to get picklist value modify this as per your requirement

public List<SelectOption> getCountries()
{
    List<SelectOption> options = new List<SelectOption>();
    Schema.DescribeFieldResult fieldResult =
    OfficeLocation__c.Country__c.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for( Schema.PicklistEntry f : ple)
    {
        options.add(new SelectOption(f.getLabel(), f.getValue()));
    }       
    return options;
}
1
  • Only the controller will not make the picklist as multiselect. Include VF code as well. Apr 8, 2016 at 10:46

You must log in to answer this question.

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