Share via


unique values for multiple columns

Question

Wednesday, December 14, 2011 8:27 AM

Hello,

I have the following problem. My list contains two columns (i.e. CATEGORIES and SUBCATEGORIES). How to ensure uniquenes for values in two columns? 

Example

CATEGORIES SUBCATEGORIES

1 1 OK

1 2 OK

2 1 OK

2 2 OK

1 2  this record should not be validated

Please help. 

Regards

All replies (4)

Friday, December 16, 2011 7:00 AM âś…Answered

currently, SharePoint does not support uniqueness check for calculated column, otherwise, the job can be easy by creating a calculated column, combining categories and subcategories.

however, you can create a column of single line of text which must be unique, and an event handler to update this new column with the combined value of category and subcategory.

Update: i had not tested it, but i guess the new column will throw out exception if uniqueness is violated, you just need to catch this exception in the event handler.


Wednesday, December 14, 2011 9:08 AM

Hi,

I don't think it is possible using out-of-the-box, but can use event receiver to check column uniqueness. Refer this link for checking uniqueness (only for one column, you can change it as per your requirement)

http://weblogs.asp.net/vikram/archive/2008/12/24/sharepoint-using-event-handler-to-make-a-column-unique.aspx

Satyam MCITP, MCPD


Wednesday, December 14, 2011 9:22 AM

Thanks for reply. I've read the article but I do not know how to make first steps (I'm just beginer with programing in SharePoint). I have Visual Studio on my computer instaled and I have working Sharepoint Server instaled on server. What should I exactly do to add event receiver to my site on Sharepoint. Could you please give me some initial hints?

Regards

 


Wednesday, December 14, 2011 9:33 AM | 1 vote

You may refer this link

http://www.learningsharepoint.com/2010/06/27/creating-event-receiver-in-sharepoint-2010/

http://sharepointx-men.com/2010/07/09/sharepoint-2010-event-receivers-part-1-create-event-receiver-for-content-types/

Satyam MCITP, MCPD