Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:


Recycle Bin | MMS | ManagedVsCrawledProperties |

Thursday, February 16, 2012

SharePoint Unique column constraint:


In SharePoint 2007, we couldn't set unique enforcements to each column or fields to avoid duplicate values in a list or library. "ID" is the only one having unique constraint in SharePoint 2007.

Before to know about enforce uniqueness feature better to get an idea on how can we handle the duplications on list items in SharePoint 2007.

 How can we set the enforce uniqueness to the columns in SharePoint 2007:
Best way to achieve enforce uniqueness to the columns in SharePoint 2007 is event handler. We can handle it by comparing the column values in ItemAdding event.

SharePoint came up with the enforce uniqueness feature. We can handle the enforce uniqueness easily through UI only for the newly created columns.
Enforce uniqueness in SharePoint 2010:
  1. SharePoint 2010 came up with that fantastic new feature called as “Unique column constraint “to avoid duplications. The unique fields are case insensitive.
  2. SPField has a new property called “EnforceUniqueValues”. It is of type Boolean and set as false [means allow duplicates] by default.
  3. We can set the enforce uniqueness for the indexed columns only.
  4. List is indexed automatically when SPColumn is defined as Unique Column Constraint.
  5. We can’t set uniqueness for all the columns. Please refer to know which all those are.
Limitations:
  • Unique Column constraint does not work on SPFolder level.
  • Possibility level to set the Uniqueness of Column is at SPList only.
  • We can’t set the enforce uniqueness for the already created columns if that columns has duplicate data.
Exceptions:
The field must first be indexed to enforce unique values." This is will come if you try to set the “EnforceUniqueValues = true” to the non-indexed fields.

This field contains duplicate values. Remove all duplicate values and try the operations again." This is will come if you try to set on a list that has existing duplicate values.

4 comments:

  1. hello, this is an old post but its seems right for my problem. Sharepoint 2010: I'm trying to enforce unique values on an existing column "single line of text" I have removed duplicates but I still get an error telling me that duplicates exist when I try to update the column settings. it seems to have indexed ok. oh and it is the "title" column but has been renamed.

    ReplyDelete
  2. I have the same issue as Tim. Anyone know how to fix?

    ReplyDelete
    Replies
    1. Can you please explain the way how did you applied this constraint so that I can identify the issue?

      Delete
  3. Me too, even I have the same issue as Tim. Any solution please!!!

    ReplyDelete