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?
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With