Can I use <apex:selectList/> and get the available items from a picklist using just a standard controller?

Current Visualforce page:

<apex:selectList value="{!Service_Order__c.Service_of_Interest__c}" size="1">
    <apex:actionSupport event="onchange" rerender="list"/>
    <apex:selectOptions value="{!Service_Order__c.Service_of_Interest__c}"/>

3 Answers 3


The normal way to present an SObject field that is of type "picklist" is:

<apex:inputField value="{!Service_Order__c.Service_of_Interest__c}"/>

The framework will recognise that it is a picklist field and render a select list and the options defined for the field automatically without you having to do any more work. It is only necessary to use apex:selectOptions or apex:selectOption if you want to build the option list yourself for some reason.

See the apex:inputField documentation for more information.

This post suggests that action:support does work with apex:inputField.

  • Keith C , I'm using the example you gave with InputField . I need an option is selected dynamically , Can give a value to inputfield in javascript?
    – VYFerrer
    Apr 19, 2016 at 8:12
  • @VirginiaFerrer Yes it is but best you ask that as a separate question if you want an example of the code. (Or Google - probably been answered somewhere already.)
    – Keith C
    Apr 19, 2016 at 14:32

Please see this example.It uses Standard list controller with select list without any extensions

<apex:page standardController="Account" recordSetvar="accounts">
<apex:pageBlock title="Viewing Accounts">
<apex:form id="theForm">
<apex:panelGrid columns="2">
  <apex:outputLabel value="View:"/>
  <apex:selectList value="{!filterId}" size="1">
    <apex:actionSupport event="onchange" rerender="list"/>
    <apex:selectOptions value="{!listviewoptions}"/>
<apex:pageBlockSection >
  <apex:dataList var="a" value="{!accounts}" id="list">

You can use apex:selectList with standard controller. But you also need some extension. In extension, you need to query available optionList using metadata.

You can use following apex code in extension:

public List<SelectOption> getSerciceOfInterestOptionList(){
    tempOptionLst = new List<SelectOption>();
    Schema.DescribeFieldResult rst5 = Service_Order__c.Service_of_Interest__c.getDescribe();
    List<Schema.PickListEntry> lst5 = rst5.getPickListValues();
    tempOptionLst.add(new SelectOption('','None'));
    for(Schema.PickListEntry obj:lst5){
        tempOptionLst.add(new SelectOption(obj.getLabel(),obj.getValue()));
    return tempOptionLst;

After that use following code in VF page:

<apex:selectList value="{!Service_Order__c.Service_of_Interest__c}" size="1">
  <apex:actionSupport event="onchange" rerender="list"/>
  <apex:selectOptions value="{!SerciceOfInterestOptionList}"/>

You must log in to answer this question.

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