Rez's SharePoint Blog Spot

:


Add me to LinkedIn   RSS Feed   Follow me on Twitter
Rez's SharePoint Blog Spot > Posts > SharePoint 2010 Enforce Unique Values in Site Columns Ability
January 18
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

Comments

Unique combinations?

Is there a way to make the combination of 2 columns unique?  say, one column will be the date and another will be "product".  
I would like to make the combination of these two unique because there must never be 2 of the same product on the same date.

Thank you
 on 9/1/2010 6:14 AM

...permission to view it

Hi. About that message in red from the screenshot, I think what they mean is that the fact that you can't have repeated numbers may give users a way to find values they're not supposed to see by doing the following:
 
Suppose I have permission to add an item, but not to see the items that other people have added. If try to add an item, and I get an error message saying that I can't add it because the value in the Order column is not unique, then I know that the number I entered is in the list which I wasn't supposed to know anything about.
 
So, for example, somebody may take advantage of this technique to determine all the numbers in the Order column, and use it for malicious purposes.
 
At least, that is what I deduced from the situation... I could be wrong.
 
Leon.
 on 9/17/2010 8:23 AM

reply to permission to view it

Except that when you activate "Enforce Unique Values", you cannon activate the fact that users can only see the elements they created.
 on 2/15/2011 2:12 AM

reply to permission to view it

Except that when you activate "Enforce Unique Values", you cannon activate the fact that users can only see the elements they created.
 on 2/15/2011 2:13 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Name


Your URL


Comments *

SPAMMER Skill Testing Question - What is 2x3? *


This field is to protect me against the barrage of spammers

Attachments