+ Start a Discussion
ben ben 2ben ben 2 

Locking one of the options of a Pick list

If I have a picklist field with 4 options
Yet I want option d to be locked so users can see it  but will not be able to select it. They they can  only  select options a,b or c. How do i implement that?


use <apex:Selectoption> it has a attribute called Itemdisabled . this is possible only if you have a visualforce page , else you can use a validation rule but it wont prevent user from selecting the value
<apex:selectList id="chooseColor" value="{!string}" size="1">
            <apex:selectOption itemValue="a" itemLabel="a"/>
            <apex:selectOption itemValue="b" itemLabel="b"/>
            <apex:selectOption itemValue="c" itemLabel="c"/>
			<apex:selectOption itemValue="d" itemLabel="d" itemDisabled="true"/>
Amit Chaudhary 8Amit Chaudhary 8
You can create report type to hide picklist valus from user.
Not sure why you would wanna show and not allow selection of an picklist,  keep in mind that if the records current value was not among the selected options it will still appear.  

use a validationrule to prevent someone from selecting it,   you could in addtion create a custom permission and add that to your rule so only certain people can select it.

If there are some 1-off cases it would need to be selected, in those cases here are two native options to filter picklist. 

1.  Consider using a 2 recordtypes/layouts to filter,  the recordtype can be changed by WF .
2.  use a dependent picklist,  where parent picklist determines to show a-d or just a-c