Section 6.12. Responding to Events


6.12. Responding to Events

Chapter 5 showed how to create email alerts that notify you when a document changes. Email alerts are sent for several general types of changes. You can also respond to changes by enabling an event handler for the library. Event handlers are code blocks activated by specific occurrences, enabling you to respond to specific changes, such as document approval or rejection , and create a response that is more complex than sending email.

Event handlers are written by programmers. As a member, you need to know how they work and how to enable them for your library. Event handlers can respond to these types of events:

  • Cancelling check-out

  • Checking in

  • Checking out

  • Copying

    animal 6-16. Creating a new member group that can approve/reject documents

  • Deleting

  • Moving or Renaming

  • Updating

When an event occurs in the document library, SharePoint calls the event handler DLL and provides an SPListEvent object that includes the type of event, the document that changed, and the properties of the document before and after the change. The code in the DLL uses that information to decide what to do. For example, your company might use an event handler to send notification to a vendor when an invoice is approved. Figure 6-17 shows how the process would work.

animal 6-17. Using an event handler to notify a vendor

Before you can use event handlers, your SharePoint administrator must enable events for the server, and your programming staff must create and install the DLL that handles the event. Usually, they will create one DLL that contains a separate class for each library.

To enable an event handler for a library:

  1. Get the DLL name and class name of the event handler from your programming staff .

  2. Navigate to the document library .

  3. Choose Modify settings and columns Change advanced settings. SharePoint displays the advanced library settings page. If you dont see this link, events have not yet been enabled for the server .

  4. In the Event Handler section, enter the DLL name and class name you got in step 1, and choose OK .

Figure 6-18 shows the event handler settings for a document library. This is the same page used to enable email submissions.

animal 6-18. Setting advanced options on a library

The Properties field shown in Figure 6-18 is for special items the event handler may use. Ask your programming staff if you need to enter anything there.



Essential SharePoint
Essential SharePoint 2007: A Practical Guide for Users, Administrators and Developers
ISBN: 0596514077
EAN: 2147483647
Year: 2005
Pages: 153
Authors: Jeff Webb

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net