locked
How to add a blank choice on a drop down menu choice list column

    Question

  • This seems like it should be easy, but I have not been able to figure it out.  Let's say I have a list with a column of type "Choice" and I use a drop-down menu.  How can I make it so that a user can choose a blank choice if they don't know what choice to pick?  It's easy for any new items.  You just set the default value to be blank and any new items will show the blank choice as default.  But if you create a new item and choose a non-blank choice and then later try to edit it and make that field blank, there is no blank option anymore.
    Monday, August 04, 2008 6:25 PM

Answers

  • Ahh,
    But you could also create a calculated column to use in the mail merge that turns your default empty choice into an empty string leaving the others intact!

    HTH,
    --Doug Ware
    http://www.elumenotion.com/blog
    • Marked as answer by Robert Phillip Thursday, August 07, 2008 4:49 PM
    Thursday, August 07, 2008 3:59 AM
  • I finally discovered another way to this, although it does have a drawback.  If you are familiar with C# and the SharePoint API you can programatically add choices to a list choice field.  The only problem is that if you go back and modify the choices through the normal SharePoint interface it will remove your blank choice.  You would have to re-execute the code every time you make a modification.  I guess it's not a big deal if you rarely have to modify the choices.

    SPSite siteCollection = new SPSite("http://yoururl"); 
     
    SPWeb web = siteCollection.OpenWeb(); 
     
    SPFieldChoice myField = (SPFieldChoice)web.Lists["YourList"].Fields["TestChoice"]; 
     
    myField.Choices.Insert(0, string.Empty); 
    myField.Update(); 
     
    web.Dispose(); 
    siteCollection.Dispose(); 

    This inserts a blank choice at the beginning of the list.


    • Marked as answer by Robert Phillip Tuesday, November 18, 2008 8:08 PM
    Tuesday, November 18, 2008 8:07 PM

All replies

  • If you allow users to add their own values (a specification when creating the Choice field) then they will be able to add a single space as their "own value".

    I have here

    http://wss.asaris.de/sites/walsh/Lists/WSSv3%20FAQ/V%20Books.aspx


    such a Choice field for whether a book is OUT or not.

    Default is blank. The only Choice value is OUT but "Allow Fill-in Choices" is set to Yes.

    (So if a book has been marked as OUT but then gets out of print or otherwise unavailable, I can and do mark it as blank again)
    Tuesday, August 05, 2008 4:36 AM
  • Mike,

    Thanks for the response.  I was hoping to avoid that, but it seems to be the only out-of-the-box way to do it.  Unfortunately it looks like this simple feature may require some custom programming.
    Tuesday, August 05, 2008 2:23 PM
  • Robert,
    The solution I have used to workaround this is to create a choice called "Unassigned".  I call it this so that it usually ends up at or near the bottom of the drop-down menu.  Then I offer some instructions under the column description informing folks that that they should pick this option if they cannot find an option that is more applicable. 

    The advantage to doing this is that I often found a need to filter out these results from the rest and this can easily be done with Equals or Does Not Equal " Unassigned"

    Hope this helps..
    Tuesday, August 05, 2008 5:37 PM
  • Fred,

    Thanks for the response.  That's a good idea, but I'm not sure if it will work in my specific situation.  We have a custom list of contacts that Marketing uses to build a mailing list.  One of the fields is a drop-down menu for suffix.  They use certain fields to pull into a template to build the mailing addresses.  I need to see how they transfer the data to ensure that we don't have something like "John Smith Unassigned" printed on an envelope going out to a customer.

    Thanks,
    Rob
    Wednesday, August 06, 2008 8:46 PM
  • Ahh,
    But you could also create a calculated column to use in the mail merge that turns your default empty choice into an empty string leaving the others intact!

    HTH,
    --Doug Ware
    http://www.elumenotion.com/blog
    • Marked as answer by Robert Phillip Thursday, August 07, 2008 4:49 PM
    Thursday, August 07, 2008 3:59 AM
  • Doug Ware said:

    Ahh,
    But you could also create a calculated column to use in the mail merge that turns your default empty choice into an empty string leaving the others intact!

    HTH,
    --Doug Ware
    http://www.elumenotion.com/blog



    Excellent idea!  I think that will work nicely.  Thanks for your help!
    Thursday, August 07, 2008 4:49 PM
  • I finally discovered another way to this, although it does have a drawback.  If you are familiar with C# and the SharePoint API you can programatically add choices to a list choice field.  The only problem is that if you go back and modify the choices through the normal SharePoint interface it will remove your blank choice.  You would have to re-execute the code every time you make a modification.  I guess it's not a big deal if you rarely have to modify the choices.

    SPSite siteCollection = new SPSite("http://yoururl"); 
     
    SPWeb web = siteCollection.OpenWeb(); 
     
    SPFieldChoice myField = (SPFieldChoice)web.Lists["YourList"].Fields["TestChoice"]; 
     
    myField.Choices.Insert(0, string.Empty); 
    myField.Update(); 
     
    web.Dispose(); 
    siteCollection.Dispose(); 

    This inserts a blank choice at the beginning of the list.


    • Marked as answer by Robert Phillip Tuesday, November 18, 2008 8:08 PM
    Tuesday, November 18, 2008 8:07 PM
  • Another Possible solution that I just tried, is to create a hidden column with an empty default value, in my case I just named the column Empty ;o)
    For the Choice box, now add a value like X/XXX and specify in description somewhere on the form that this value is to be used if the person wishes to clear a choice.
    Then create a workflow looking on changes:

    IF Field:value equals X
    THEN set field:value to List:Empty

    This will set the field to an empty value.
    Thursday, July 02, 2009 2:00 PM
  • I struggled with this too.

    If you have a Drop Down List with either 1 or more than 1 item and want an additional blank; place the cursor after the last item hit ENTER and viola.

    Rock On
    Tuesday, February 02, 2010 8:46 PM
  • This will give you a blank in the NewItem form. It will not give you a blank in the Edit form.
    Wednesday, February 17, 2010 8:56 PM
  • Choice fields are often used within SharePoint lists to display choice options like Gender, Status, etc and these choice options can be displayed using Radio Button and Dropdown formats.
     
    Provided below is a code sample in C#.Net which describes the creation of a choice field programmatically using SharePoint API.
     
    /* get the newly added choice field instance */
    SPFieldChoice chFldGender = (SPFieldChoice)lst.Fields["Gender"];
     
    Any suggestions are appreciated.Hope it did answer the question.

    Cheers, Eliza
    Friday, June 18, 2010 8:49 AM