Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Title field enforce unique values in custom list definition (SharePoint 2010)

I have a custom list definition, and I am trying to rename the custom 'Title' field to 'Name' and to make it enforce unique values. First, I referenced it in the custom content type (Elements.xml):

<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"  Name="Title"/>

and then in the list template (Schema.xml):

<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Name" Type="Text" AllowDuplicateValues="FALSE" Required="TRUE"></Field>

The field is renamed, but I can add list items with the same title. If I go in the field settings page, the Enforce unique values property is set to false. How can I enable it, what I am doing wrong?

like image 941
kjv Avatar asked May 15 '11 17:05

kjv


People also ask

How do you enforce unique values in a SharePoint list?

What is “enforce unique values” feature? Enforce unique values is a setting on a SharePoint metadata column. When you create a new metadata column, you can check off the appropriate radio button to enable it (it is disabled by default).


1 Answers

In order to make this work you need to add:

Required="TRUE" EnforceUniqueValues="TRUE" Indexed="TRUE"

And Remove

AllowDuplicateValues

To your <Field> in both the Elements.xml and the Schema.xml of your list definition.

like image 123
MikeKusold Avatar answered Sep 21 '22 03:09

MikeKusold