Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

SharePoint 2010 - how to make multi columns unique value ?

Posted on 2012-09-14
2
Medium Priority
?
1,551 Views
Last Modified: 2012-09-17
hi
i'm implementing a sand box solution where is should have more than one column a unique key, i have to use the item adding event receiver but how to get the current adding item field values to know if this item is occurred within the list.

thanks
0
Comment
Question by:Rawasi
  • 2
2 Comments
 
LVL 1

Author Comment

by:Rawasi
ID: 38404598
1- create UniqueID column and make it unique.
2- create an event receiver as follows:
public override void ItemAdding(SPItemEventProperties properties)
        {
            string Name = properties.AfterProperties["Name"].ToString();
            string Title = properties.AfterProperties["Title"].ToString();
            StringBuilder StringBuilder = new StringBuilder(Name);
            StringBuilder.Append("-");
            StringBuilder.Append(Title);
            properties.AfterProperties["UniqueID0"] = StringBuilder.ToString();
            base.ItemAdding(properties);
        }
0
 
LVL 1

Accepted Solution

by:
Rawasi earned 0 total points
ID: 38404599
1- create UniqueID column and make it unique.
2- create an event receiver as follows:
public override void ItemAdding(SPItemEventProperties properties)
        {
            string Name = properties.AfterProperties["Name"].ToString();
            string Title = properties.AfterProperties["Title"].ToString();
            StringBuilder StringBuilder = new StringBuilder(Name);
            StringBuilder.Append("-");
            StringBuilder.Append(Title);
            properties.AfterProperties["UniqueID0"] = StringBuilder.ToString();
            base.ItemAdding(properties);
        }
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question