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"/>
开发者_如何学Python
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?
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.
精彩评论