I’ve recently been introduced to Sharepoint here at work. I must
say, I’m impressed with the out-of-box features. Lists, forms,
custom fields, reporting, filters, document storage, etc. are all great
things to have, and the user interface is excellent if you’re using IE
and it degrades gracefully if using firefox (you lose a lot of cool
dhtml though
).
Something that I wanted right away was a custom workflow engine.
Basically when list items get created, updated, or deleted, I want to
be able to inject my own rules engine that can execute custom business
rules based on the action. Suppose I have a list that represents
bugs in my software product and I want a new task to be created in my
Outlook whenever a bug is added to the list. You can’t currently
do that with the standard Sharepoint lists. Now, there is some
built-in functionality. There is the notion of “alerts” whereby
you can subscribe to receive emails when items are added, updated, or
removed from the lists, but thats rather simplistic. I don’t want my
inbox filling up with junk, I wanted a task to be created! All I
really want is programmatic access to those same “alert” calls, just
give me a simple “ItemAdded”, “ItemUpdated”, etc. events on the list,
it can’t be that hard to do as Sharepoint already supports sending me
emails! (I can’t believe that I just used the phrase “it can’t be
that hard to do” cause I HATE it when people say that shit)
After scouring the internet, I have come to accept that it cannot be
done. I’ve heard that this is a feature that is coming in a
future release of Sharepoint, which is good to hear. The
interesting thing to note is that there is a special type of list in
Sharepoint called Document Libraries. These are essentially lists
of files that you can upload into Sharepoint. These lists DO have event handlers.
Not only do they support insert, update, and delete events, they even
have move, copy, check-in, check-out, and cancel check-out.
Another interesting tidbit is that the class that represents these
Document Libraries in the Sharepoint API, SPDocumentLibrary, inherits
from the plain old list class, SPList. The SPList class contains certain properties that define what code to run
for these events that Document Libraries expose. So you have an
instance of the SPDocumentLibrary and you can set these properties so
that your custom code can execute for the given events. Guess
what happens if you try to set the properties for just a regular SPList
instance: NotSupportedException. Fantastic. They were so close,
but alas, we will wait for a future release