Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have the following field definition in the Schema.XML file for a custom list definition. Per the documentation setting EnforceUniqueValues and Indexed to true should enforce a uniqueness constraint on the field, but I am able to add duplicate values across list items through the UI.

<Fields>
      <Field Type="Text" 
             DisplayName="Client" 
             Required="TRUE" 
             EnforceUniqueValues="TRUE" 
             Indexed="TRUE" 
             MaxLength="255" 
             ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" 
             SourceID="{$ListId:Lists/Client;}" 
             StaticName="Title" 
             Name="Title" 
             ColName="nvarchar4" 
             RowOrdinal="0" />    
</Fields>

Am I doing something wrong here? Is there somewhere else I need to set this attribute?

share|improve this question
    
Curious. Was this in the context of a Sandboxed or Farm solution? –  Brian Apr 3 '12 at 16:25
    
It was a farm solution. –  JohnFx Apr 3 '12 at 18:33
add comment

1 Answer

up vote 2 down vote accepted

Have you tried this for other fields than Title?

The spec for SPField.EnforceUniqueValues states that

You cannot set this property to true for a built-in field or for a site column.

Not 100% that this is valid for the declarative approachs for custom schemas, but test with another field "test" of type text and you will find out...

share|improve this answer
1  
Ugh. I bet that's it. SharePoint is a minefield of stuff like this. –  JohnFx Jun 22 '11 at 22:41
add comment

Your Answer

 
discard

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.