Welcome to EMC Consulting Blogs Sign in | Join | Help

Paul Galvin's Blog

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.

Published 25 March 2008 19:37 by Anonymous
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

taskworkflow said:

Cool Stuff

All the steps are clearly mentioned.

Thanks

December 25, 2008 08:36
 

dotnetguts said:

I am working on sharepoint for quiet sometime, but never applied my hands on patterns.

Could you list basic and must use patterns list for sharepoint.

I have prepared a list of basic patterns, but not sure and would like to take opinion from experts of industry.

http://dotnetguts.blogspot.com/2009/09/patterns-and-practices-tutorial-for.html

September 13, 2009 04:10

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Personal Edition), by Telligent Systems