Make sure event handlers are enabled on the site where your survey is.
1. To enable event handlers for your site, go to “SharePoint Central Administration”.
2. Select “Application Management” tab and then select “Web application settings” in “SharePoint Web Application Management” section.
3. Select your web application from the drop down. Click “Change Web Application” and then select your web application from the form that opens.
4. Scroll down and locate the “Event Handlers” section and turn them on.
5. Now go back to your site. You are ready to write an event handler
6. Start a new “Class library” project in VS and select C# as the programming language. Project will contain just a few lines of code.
Add Microsoft.SharePoint reference from C:\Program Files\Common Files\Microsoft Shared\web server
public class UniqueID : SPItemEventReceiver
private static int GetUniqueId(SPWeb web)
int returnValue = -1;
int retryCounter = 0;
int uniqueId = -1;
// Get the list and list item
SPList list = web.Lists[“IPD Form”];
// Set the value to return
returnValue = list.ItemCount + 1;
catch (Exception ex)
// Handle the exception by retrying 5 times
retryCounter += 1;
if (retryCounter “Processes” and select the “w3wp.exe” process (may be more than one – select them all) and hit ok. when asked, select the “managedd code” option only (not script and sql)