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
anu_karthianu_karthi 

How to remove -None- option in picklist

Hi everyone,

 

   In my appliction i am using picklist field.My requirement is, in picklist i should not be display "-None-" option and it won't accept null values also.if any one knows this plz tell me the solution.

 

Thanks in advance,

anu..

gm_sfdc_powerdegm_sfdc_powerde
Add required="true" attribute to your picklist tag.
ShamSham
In the field metadata of picklist ,try setting "first value as default value"
anu_karthianu_karthi

Thanks for ur reply,

 

I had already tried with the default value while creating the picklist but again -None- option is displayed.

So tell me is it possible to do this functionaility in salesforce or else can i try with Visual force pages.

 

Thanks,

Anu..

sumitasumita

Make a value the default value and make the field required=true on the page layout.

 The none option will go..

 

 

PS: try searching first, then posting questions..this q has already been solved on the forums..

EG: http://community.salesforce.com/sforce/board/message?message.uid=83238

 

Message Edited by sumita on 11-24-2009 01:15 AM
Cool_DevloperCool_Devloper

And also Anu,

Please do not post the same question on multiple posts!

Cool_D

Paulo CastroPaulo Castro

Hi guys,

 

 I tried what you suggested but I'm still getting the '-- none --' option.

 I set the inputField tag as required, the page layout field as required and set the first option as default...

 

 I'm using a custom page to buid this form, is that the problem??

 

 Tnx for any help!

 

 Best regards

 

 PH

 

rnavaretternavarette

Has anyone been able to solve this problem on a custom (VisualForce) page?  The best that I've been able to do without creating my own picklist is to set the required checkbox on the apex:inputField.  This still offers '-- None --' as an option but causes validation to fail.  Ideally, the '-- None --' shouldn't even show up.

SteveBowerSteveBower

I'd think you can do this via configuration, but, if for some reason you can't, and you're in a VF page, you can just do it yourself.

 

Use Javascript to take the Id of the SelectList, then go into it's SelectOption children via the DOM and remove the option that is for "None".   After all, at the end of the day it's all HTML and you can play with it via javascript.  Ugly... I'd look at configuration again.

 

Best, Steve.

rnavaretternavarette

Thanks Steve.

 

If it comes down to it, I'll go back to building the select list on my own using describe on the field.  Was really hoping that this simple functionality existed out of the box.

 

ray

Christopher_Alun_LewisChristopher_Alun_Lewis

I am also frustrated at how this is not configurable through the object field. I have (like mavarette hinted) created a select list for the field using Schema.DescribeFieldResult as an alternative solution. 

 

If you are wandering how to do this, I have provided an example in my blog, see here:

http://christopheralunlewis.blogspot.com/2010/10/creating-picklist-in-visualforce-page.html

 

see The Christopher Alun Lewis Blog for Salesforce news, comment and development tips and tricks

 

Christopher_Alun_LewisChristopher_Alun_Lewis

Hello All,

 

If anyone is still curious about how to remove the -none- option in a picklist, I have developed my solution further so that it is now contained in a re-usable Visualforce component:

 

See this post in my blog for more info:

http://christopheralunlewis.blogspot.co.uk/2012/08/visualforce-component-that-creates.html

 

see The Christopher Alun Lewis Blog for Salesforce news, comment and development tips and tricks

Alon Waisman 3Alon Waisman 3

I know it's not exactly the same, but instead of removing the '--None--', I needed to translate it to French if we were displaying the French version of a page. I wrote up some quick Javascript to do the job. Wanted to add it here in case it could help someone. You could easily change the last anonymous function to remove the option instead of changing it's text.


if ( {!isFrench} ) { translate_none_options_to_french(); }

function translate_none_options_to_french() {
     j$('option').filter(function () {return j$(this).html() == "--None--";}).each(function(index, option){option.text = '--Aucun--';})
}
 

Ivy CartagenasIvy Cartagenas
is there any new solution in removing --None-- option from the picklist?
MOHD ASIMMOHD ASIM
Hi ivy Cartagenas,Paulo Castro
on Visualforce page if the field type is input field as required="true",whenever u save the record with "None" option.it will not let u save.
if it works.please mark my answer as correct.
Thanks.