Archive

Archive for August, 2010

Unique Column/Field in SharePoint List

August 9th, 2010 6 comments

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.