SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a custom SharePoint list on feature activation. Though it works fine but I want that if the list with same name already exists it should overwrite that list and create the new one. I want to avoid checking if list already exists code.

Also some of my list columns are of type "Choice". How can i allow multi select values and add choice values for that column?

I am working with SharePoint 2010 and using SPList object.

share|improve this question
what did you try ? – Steve B Jun 7 '12 at 12:46
What happens to items in the list if the list already exists? – SpartanDonut Jun 7 '12 at 15:09
It wont create the list if it already exists. – V.B Jun 8 '12 at 5:10
up vote 2 down vote accepted

I don't think there is an overwrite function. You are going to have to check if one exists first, delete it and then recreate it. Or you could write code to look at the existing one and add/remove any columns or settings as needed.

As for the choice, I've always had the best luck using SPList.Fields.AddFieldAsXml(xml). The format looks something like this:

<Field Type="Choice" DisplayName="Color" Required="FALSE" Format="Dropdown" FillInChoice="FALSE" Name="Color" ColName="nvarchar4">
share|improve this answer

There is no option for overwriting so you have to remove the old list yourselves.

But I'd suggest you don't do that on feature activation. If you want just to overwrite I assume that your list name/url is very specific to your feature as you'd otherwise risk deleting endusers data. If the list can only be created by your feature and don't contain data needed if the users deactivate/activate the feature then you should delete it in feature deactivation.

To make a choice field allow multiple values you have to set the Format="RadioButtons"

share|improve this answer
Thanks for valuable suggestions per. – V.B Jun 8 '12 at 5:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.