Ben has a wealth of experience fulfilling customer requirements by using Microsoft technologies. Microsoft Visual Studio provides a project type that enables you to build event receivers that perform actions before or after selected events on a Microsoft SharePoint site. This example shows how to add an event to the adding and updating actions for custom list items. Overriding the itemAdding event and the itemUpdating event.
Verifying that the list to which the item is being added is the Open Position list. Elevating permissions so that the code can access a secure site to retrieve approved job titles. Comparing approved Job Titles with the title of a new item that is created in the Open Position list. Canceling the event when the Job Title is not approved.
In this example, a secure subsite contains a list named Job Definitions that specifies allowed job titles for roles in the organization. Along with job titles, the list also contains confidential salary information for the job title and is therefore secured from users. In the main site, a list named Open Positions tracks vacancies in the organization. You create two event receivers for the itemAdding and itemUpdating events that verify that the title of the open position matches one of the approved titles in the Job Definitions list.
Prerequisites Before you start, create the subsite and lists that you will need. In the New Site dialog box, click Blank Site. On the right of the dialog box, click More Options. In the Title box, type Job Definitions. In the Visitors to this site section, select Use an existing group, and then select Team Site Owners.
Permanent, Contract Add several jobs to this list. Note the titles that you specify for each job that you create because you will need them later. To create the Open Positions list In the parent site, create a custom list named Open Positions with the following columns: On the File menu, click New, and then click Project. In the template list, click Event Receiver. In the Name box, type VerifyJob.
Leave other fields with their default values, and click OK. In the What local site do you want to use for debugging? Select the Deploy as a farm solution option, and then click Next. In the What Item should be the event source? Under Handle the following events, select the An item is being added and the An item is being updated check boxes. To modify the events receiver file In the events receiver file, add the following code to the class.