SharePoint 2010 Enforce Unique Values in Site Columns Ability

SharePoint 2010 Enforce Unique Values in Site Columns Ability

For those folks who are constantly performing site column additions and manipulation within the SharePoint environment, SharePoint 2010 now has the ability to enforce unique values at the site column level [1]. 

For example, I have a pages library where a user can create publishing article web pages with my own custom page layout.  I want a content query web part on the home page whereby it pulls information for two of the article web pages in that pages library, however, I only want to pull them in a specific order that the user must specify.

In the old SharePoint 2007 platform, I would create an “Order” site column and attach it to the article content type and have the user fill it in with a number (i.e. 1, 2, 3, etc….).  I didn’t have an easy mechanism to ensure that the user didn’t use same number.

Now in the new SharePoint 2010 platform, we have a yes/no option when creating a site column that says “Enforce unique values:”. 

image

By selecting this, it now allows me to ensure that the user won’t select the same number twice.  When selecting this option, SharePoint will prompt you and let you know that it needs to index the column to make this happen.  This way I can filter and order my content query by these new parameters to show what I want in the order I want it.

When you try to add a duplicate Order value and save the page, it doesn’t seem to work at first glance, this is where I thought that Microsoft would place the enforce unique value check however, Microsoft did it on publishing.  This probably makes the most sense as people can have pages in draft and there is no reason it should force unique values at that point.  When i try to publish the page, I get the following message, which is what I wanted:

“Cannot complete this action. The list item could not be added or updated because duplicate values were found in the following field(s) in the list: [Order].”

image 

Of course, this is still beta so Microsoft has a few button bugs but at least it’s catching the unique value check.

*** Update ***: Out of curiosity, I went to go look at the site column that was attached to the pages list and I get the following message:

“This list or document library has content approval enabled. A column that enforces unique values may let users determine information about a list item or document even if they do not have permission to view it.”

image

Not sure what this means.

[1] http://msdn.microsoft.com/en-us/library/ee536168(office.14).aspx

Leave a Reply

Your email address will not be published. Required fields are marked *