Home > MOSS, SharePoint 2010 > Unique Column/Field in SharePoint List

Unique Column/Field in SharePoint List

August 9th, 2010

It is always a desire to have unique field in SharePoint list. Sometimes you have to replicate a database table and sometimes it could be a special requirement. Recently when I have been asked to have a unique field in a SharePoint list, I searched for it. Thanks to CodePlex. There is a solution called Unique Column Policy.

It is actually a feature. It creates a new information policy that allows you to specify a column in a list or library that should have unique values. Unfortunately on the website there is not enough information on how to use it. So I created this blog, I will show how it works.

First of all you need to download it. You can download it from this link. (Download). Then you need to install it on your SharePoint server. For this addsolution to solution store.

stsadm –o addsolution –filename UniqueColumnPolicy.wsp

Now deploy the solution. You can deploy it either from the stsadm command or you can deploy it using the SharePoint Central Administration site. This solution deploys globally. So you cannot just deploy it for a single site collection. Once your solution is deployed. Now you can create unique columns in SharePoint lists.

In order to, apply it on a column. Create a new column in a SharePoint list. Now open the list settings page and open the Information management Policy Settings link.

List Settings Page

In order to, apply it on a column. Create a new column in a SharePoint list. Now open the list settings page and open the Information management Policy Settings link. Select ‘Define a Policy’ and click ‘OK’.

Information Management Policy Settings

It will open edit policy page. Now select ‘Enable Unique Column Policy’.

Edit PolicySelect the field you want to use for unique values.

Select a field

Now when you try to add the same value you used before in unique column. It will give you an error like this.

Unique Column ErrorIt will show the same error when you try to update and item and give it same value you used before in any other list item. Good thing is this also works with datasheet view.

DataSheet View

Like in the above image, we tried to use the same value UC_999 in unique column field. When we moved to next column. It displayed an error icon in front of the affected row. This is the error to notify user that duplicated values are not allowed in this column. Click on the icon and you can see more details.

DataSheet View - Error Details

In simple words this feature is amazing, and it gives more power to SharePoint list.

I hope this will help implementing unique column/field in SharePoint list.

  1. Kaleu Delphino
    September 15th, 2010 at 19:00 | #1

    Hi.

    I installed and tested the feature and it worked fine. But now it’s not working anymore. I can create 2 items with same column value. But if I try again, the feature works and does not allow a new registration.

    Any ideas?

  2. admin
    September 17th, 2010 at 00:59 | #2

    Hi
    I’m using this column policy for multiple lists and I haven’t seen any problem. This policy actually attach an EventHandler with ItemAdding and ItemUpdating of the list. If you can then please verify that this EventHandler is attached or to make it simple just remove the policy and apply it again.
    If nothing works then do let me know I can provide a simple code for EventHandler which can ensnure unique column in a list.

    Thanks

  3. Steve
    October 8th, 2010 at 15:34 | #3

    I tried this out and it appears to work fine for text based columns, but for columns of “Person or Group”, it doesn’t appear to work.

  4. October 17th, 2010 at 03:19 | #4

    Well done This was a excellent piece of writing. Do go on as you are. I shall be eagerly waiting.

    - Jamya BROOKINS

  5. November 10th, 2010 at 08:37 | #5

    Good article it’s really clear, i will try it! Very good article and blog, poker is good to !

    - Aleah BARGER

  6. September 5th, 2011 at 00:05 | #6

    I liked your article is an interesting technology
    thanks to google I found you

Comments are closed.