This is my 1st week taking over my company's salesforce application, so I'm an extreme newbie. I apologize if this is an exceptionally simple issue. I have details listed below, but basically, I need to know how to specify which values I want to use to populate a dropdown list. For example, display all values from table_X where the id = 1,3, or 5, into the dropdown list.

On one of our salesforce pages, we have a dropdown list. Normally this list simply displays all values from a particular salesforce table. Now however, I need to change this to the following:

  • If the client of this particular order is associated with is "ABC Company", only show 3 values in the dropdown list: New, Pending, & Shipped.
  • Exclude all other values from this drop down list

Here's the apex code:

<apex:column title="Shipping Status" >
                        <apex:facet name="header">
                            <apex:outputLabel title="Shipping Satus">Status
                            <apex:image value="/s.gif" alt="" styleclass="helpIcon"/>
                        <apex:inputField id="shippingStatus" value="{!i.item.shipping_Status__c}" rendered="{!i.editable}" style="width:80%"/>
                        <apex:outputField value="{!i.item.shipping_Status__c}" rendered="{!!i.editable}" style="width:80%"/>

And here's some code I found (although I'm not sure if this pertains to what I need. Still new to this):

public List<ShipStatusResult> ShipStatusResults {
    get {
        if (ShipStatusResults == null) {
            ShipStatusResults = new List<ShipStatusResult>();
        return ClinicalResults;
public class ShipStatusResult{
    public Shipment_Status__c item {get; set;}    
    public boolean editable {get; set;}
    public string state {get; set;}
    public boolean ShipmentStatusIsEditable{get;set;}       

Like I said, this may not be the full code, but hopefully it helps.


  • I apologize that my example's a little vague, so even if you can just point me in the right direction or a good link about how to do this, I would greatly appreciate it!
    – goalie35
    Commented May 25, 2017 at 18:06

1 Answer 1


I would suggest you the build the picklist values in apex controller code based on Account.

So, you can specify particular account type or recordtype or specific record indicator for which you will prepare specific set of picklist values. Because today you are looking for ABC Company, tomorrow it can be XYZ Company.

Create a custom settings or custom metadata type which will hold the mapping between Account Type and picklist values.

This is a sample code to prepare picklist values.

//retrieve mapping entries from Custom settings
Map<String, String> valueMap = new Map<String, String>();
valueMap.put(/* add desired picklist entries New, Pending, & Shipped*/);
//if you want to display all the values then do not put in the map.
//retrieve picklist values based on the valueMap
getPicklistValues(ShipStatusResult, shipping_Status__c,valueMap);

public static List<SelectOption> getPicklistValues(SObject obj, String fld, Map<String,String> valueMap)
    List<SelectOption> options = new List<SelectOption>();
    // Get the object type of the SObject.
    Schema.sObjectType objType = obj.getSObjectType();
    // Describe the SObject using its object type.
    Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
    // Get a map of fields for the SObject
    map<string, schema.sobjectfield> fieldMap = objDescribe.fields.getMap();
    // Get the list of picklist values for this field.
    List<Schema.PicklistEntry> values =
    // Add these values to the select option list.
    for (Schema.PicklistEntry a : values)
        //here you will add picklist entries based on valueMap entries.
                options.add(new SelectOption(a.getLabel(), a.getValue()));
            //here you want to display all the values
            options.add(new SelectOption(a.getLabel(), a.getValue()));
    return options;

Rather than using apex:inputField, use apex:selectList to display picklist values in the visualforce.

Hope, it will help you to find good direction.

You must log in to answer this question.

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