Paul's profilePaul Galvin's SharePoint...BlogListsSkyDrive Tools Help

Blog


    March 25

    Towards SharePoint Technical Design Patterns: SharePoint Designer Workflow + Event Receiver = High Potency Cocktail

    One of the emerging patterns I find in crafting SharePoint solutions leverages SharePoint Designer workflow and an event receiver.

    Here is a business scenario to put it in context:

    • I upload a document to a doc lib.
    • I kick off multi-step workflow created using SharePoint Designer.
    • At some point during that process, workflow assigns a task to someone (via collect data from user or assign a task).
    • We want to use a KPI to track how long that task is awaiting completion.  The KPI shows green for tasks that are completed or due more than 3 days from now.  It shows yellow if the task is due tomorrow or today.  It shows red if the task is past due.
    • Here's the kicker: I want the date that drives that KPI to be holiday-aware.

    I can't calculate a holiday-aware due date in SharePoint Designer workflow very easily.  I would have to create a custom action or use a 3rd party tool.  However, it's easy enough to calculate such a date in an event receiver.  Merge those two together and we get a pattern like this:

    • Define a hidden yes/no site column on the document library labeled "DoCalcualteDueDate".
    • Initialize it to false.
    • At the appropriate time in the workflow (e.g. just before the "collect data" action), assign that value to True.
    • An ItemUpdate() event receiver looks to see if "DoCalculateDueDate" is true.  Since the event receiver runs on every update, "DoCalculateDueDate" is normally false.
    • When workflow assigns DoCalculateDueDate to true, the event receiver calculates the holiday-aware due date.
    • When the event receiver does this calculation, it sets the DoCalculateDueDate flag to false.

    In the end, SPD workflow is communicated with an event receiver via the DoCalculateDueDate semaphore and we have holiday-aware due dates that are assigned at the exactly correct moment in the workflow's life.  SharePoint Designer controls when the due date is assigned but the event receiver performs the actual calculation and assignment.

    </end>

    Subscribe to my blog.

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!877.trak
    Weblogs that reference this entry
    • None