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
Figure 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.
Figure 6-17. Using an event handler ...
Get Essential SharePoint now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.