function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ChinnoduChinnodu 

I want remove only one vlaue from picklist in VF page

I am having a picklist field(Status) with values A,B,C and D

 I want to hide or remove only D  value from Piclist(Status) in the VF page

Can someone pls help me with the code.

Regards,
Viswa.
Vasani ParthVasani Parth
The below code is an extract from my folder and it worked for me,

You can hide specific picklist value through controller and below is the sample code:
 
    ------------- Controller Code ---------------  
Public string propPickValSelected { get; set; }
                                public List<SelectOption> getPickLstValue()
                                {
                                                List<SelectOption> options = new List<SelectOption>();
                                                Schema.DescribeFieldResult fieldResult = Account.PickLst__c.getDescribe();
                                                List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
                                                for(Schema.PicklistEntry f : ple)
                                                {
                                                                if(f.getValue() != 'A- 123')
                                                                {
                                                                                options.add(new SelectOption(f.getLabel(), f.getValue()));
                                                                }
                                                } 
                                    return options;           
                                }
      --------------- VF Page Code -----------------
<apex:selectList title="PickList1" size="1" value="{!propPickValSelected}" styleClass="form-select">
                                                <apex:selectOptions value="{!PickLstValue}"/>
                                </apex:selectList>

Please mark this as the best answer if this helps
NagendraNagendra (Salesforce Developers) 
Hi viswa,

You can hide specific picklist value through controller and below is the sample code:
 
------------- Controller Code ---------------
                                Public string propPickValSelected { get; set; }
                                public List<SelectOption> getPickLstValue()
                                {
                                                List<SelectOption> options = new List<SelectOption>();
                                                Schema.DescribeFieldResult fieldResult = Account.PickLst__c.getDescribe();
                                                List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
                                                for(Schema.PicklistEntry f : ple)
                                                {
                                                                if(f.getValue() != 'A- 123')
                                                                {
                                                                                options.add(new SelectOption(f.getLabel(), f.getValue()));
                                                                }
                                                } 
                                    return options;           
                                }
 
                                --------------- VF Page Code -----------------
                                <apex:selectList title="PickList1" size="1" value="{!propPickValSelected}" styleClass="form-select">
                                                <apex:selectOptions value="{!PickLstValue}"/>
                                </apex:selectList>
For more information lindly refer to the below link
https://developer.salesforce.com/forums/?id=906F00000009731IAA

Please mark my solution as the best answer if it helps you.

Best Regards,
Nagendra.P            
      
Jasveer SinghJasveer Singh
Hi viswa

please look this code
 
<apex:page controller="removeOneValueFromPickList">
<apex:form >
                                 <apex:selectList title="PickList1" size="1" value="{!propPickValSelected}" styleClass="form-select">
                                                <apex:selectOptions value="{!PickLstValue}"/>
                                </apex:selectList>
</apex:form>
</apex:page>
 
public class removeOneValueFromPickList {

Public string propPickValSelected { get; set; }
                                public List<SelectOption> getPickLstValue()
                                {
                                                List<SelectOption> options = new List<SelectOption>();
                                                Schema.DescribeFieldResult fieldResult = Account.SLA__c.getDescribe();
                                                List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
                                                for(Schema.PicklistEntry f : ple)
                                                {
                                                                if(f.getValue() != 'Gold')
                                                                {
                                                                                options.add(new SelectOption(f.getLabel(), f.getValue()));
                                                                }
                                                } 
                                    return options;           
                                }
}

u change change Gold into D
I think your desire result will get.....

Thanks & Regards
Jasveer Singh