4

I have custom content type, custom list definition from this content type, and list instance in my visual studio project. I could not set Enforce Unique Values for Title Field. How can I achieve this.

Here is what I did:

In custom content type, I included title field (Elements.xml):

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Type="Text" Required="TRUE" EnforceUniqueValues="TRUE" Indexed="TRUE"  />  
 <!-- Parent ContentType: Item (0x01) -->
 <ContentType ...>
<FieldRefs>
  <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" />
</FieldRefs>
</ContentType>
</Elements>

Then in my custom list definition, I also included Title field (Schema.xml):

<ContentTypes>
  <ContentType ID="0x0100db7f2ee33f6f48efaac128f9e90eafd3" Name="..." Group="Micts Content Types" Description="..." Inherits="TRUE" Version="0">
    <FieldRefs>
      <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" />
    </FieldRefs>
  </ContentType>
</ContentTypes>
<Fields>
  <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Type="Text" Required="TRUE" EnforceUniqueValues="TRUE" Indexed="TRUE"  />
</Fields>
0

If "Title" is a custom field then you can override Validate method for your field type, or you can add a event receiver to your list. A similar question is explaining every possible way.

You can also try CodePlex

Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.