Custom Workflow in Sharepoint

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 :)

3 Comments

  1. Anonymous said,

    Wrote on September 13, 2005 @ 10:26 am

    You’ll be interested in following some news coming out about the next version of SharePoint this week at PDC. ;)

  2. Anonymous said,

    Wrote on September 15, 2005 @ 5:37 am

    Perhaps not exactly what you’re after, but there is a 3rd party product that can produce custom work flow and document flow in Sharepoint. http://www.sharevis.com

  3. Anonymous said,

    Wrote on October 7, 2005 @ 6:53 am

    Before any document libraries can raise events on the server, WSS must be configured to enable events. The default configuration of a WSS virtual server does not allow events to be raised for document libraries, so you have to explicitly enable this feature before your custom event sink objects will be notified of events. You can do that through the administration Web site, by using the SharePoint command-line administration tool STSADM.EXE, or by using the WSS server-side object model. Enabling event handlers programmatically is simple using code like that shown here:

    SPGlobalAdmin globalAdmin = new SPGlobalAdmin();

    System.Uri uri = new System.Uri(”http://localhost:8080″);
    SPVirtualServer vServer = globalAdmin.OpenVirtualServer(uri);

    SPVirtualServerConfig vConfig = vServer.Config;
    vConfig.EventHandlersEnabled = true;
    vConfig.Properties.Update();

    globalAdmin.Close();

Comment RSS