SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

The article here : describes how to set the unique field using code, I guess you could put this code in the feature receiver activated event.

Is there an easy way to define field uniqueness in the XML field definition.

My first guess would be :


But I'm getting this error:

Error occurred in deployment step 'Activate Features': This field must be indexed to enforce unique values


I realized I was setting this in the raw field definition, not in the list instance where I think it would be more suitable, so I added All fields of the content type to the fields collection for the list instance, and set the property there, no error during deployment, but it ignores the unique binding.

share|improve this question
Not sure how I solved the issue, but the problem was not in the field definition. As it turns out the unique constraint can be enforced at the field definition level. – user879 Dec 7 '10 at 18:10

Just add Indexed="TRUE" in the <Field> element

share|improve this answer

Try using this utility to generate the markup for the field definitions and content types which you have created in SharePoint 2010 using the UI. This utility can generate the ferature markup which you can later incorporate in your solution as is:

share|improve this answer

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.