I am building a piece of functionality where I need to filter a picklist depending on the user profile that access the functionality. The behavior I want to build is the following: User with specific profile access a VF, the VF offers a picklist with values depending on the profile. If a different user access the will be offered a different set of picklist values.

The code I am using is fairly simple, the extension looks like this:

public List<String> productFamily {get;set;}
public String selectedFamily {get;set;}
productFamily = new List<String>();
Schema.DescribeFieldResult productCategoryDescription = SVMXC__Installed_Product__c.INS_G_Product_Category__c .getDescribe();

for (Schema.Picklistentry picklistEntry:productCategoryDescription.getPicklistValues()){



The VF section looks like this:

    <apex:outputLabel value="Product Family"/>
    <apex:input id="productFamily" type="text" value="{!selectedFamily}"

The different profiles have different visibility settings for the picklist values. However, when I access two different profiles, the picklist gets loaded with all the values contained in the field.

When I fetch the DescribeFieldResult I see I can use isAccessible to get access to the fields allowed by Profile, but I cannot access it by values in the field.

Is there any other approach to fill the picklist in the backend without using record types? (they are used for a different purpose). Is there any other API method that could help me fill those values?

Thank you


1 Answer 1


The only platform mechanism to vary which picklist values are shown is based on the record type. So if you can't use those because they are being used for a different variation, you will have to write your own code - the platform's meta data can't represent what you want.

That code probably needs to have two parts:

  1. A way of defining the values to display for a particular profile. As you can't predict the profile names in use in the org your managed package is installed in, you probably will need to use a public custom setting to allow the profile names to be configured. For example, you could use a list custom setting where the name is the profile name and the values are a comma separated list of picklist values that you want displayed for that profile.
  2. Some code that generates the picklist values for a particular profile. UserInfo.getProfileId() will give you the user's profile ID and you can then query the profile name and use that to lookup your custom setting values and display those.
  • Very smart solution. I buy it :)
    – magandrez
    Commented Nov 10, 2014 at 13:41

You must log in to answer this question.

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