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()){
productFamily.add(pickListEntry.getLabel());
}
The VF section looks like this:
<apex:pageBlockSectionItem>
<apex:outputLabel value="Product Family"/>
<apex:input id="productFamily" type="text" value="{!selectedFamily}"
list="{!productFamily}"/>
</apex:pageBlockSectionItem>
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