Workflow workarounds: tracking individual column changes

Posted by PeterBrunone on ASP.net Weblogs See other posts from ASP.net Weblogs or by PeterBrunone
Published on Mon, 07 Mar 2011 15:46:00 GMT Indexed on 2011/03/07 16:11 UTC
Read the original article Hit count: 288

This post is long overdue, but since the question keeps popping up on various SharePoint discussion lists, I figured I'd document the answer here (next time I can just post a link instead of typing the whole thing out again).

In short, you cannot trigger a SharePoint workflow when a column changes; you can only use the ItemChanged event.  To get more granular, then, you need to add some extra bits.

Let's say you have a list called "5K Races" with a column called StartTime, and you want to execute some actions when the StartTime value changes.  Simply perform the following steps:

1)  Create an additional column (same datatype) called OldStartTime.

2)  When the workflow starts, compare StartTime to OldStartTime. 

  a) If they are equal, then do nothing (end). 

  b) If they are NOT equal, proceed with your workflow.

3)  If 2b, then set OldStartTime to the value of StartTime.

By performing step 3, you ensure that by the end of the workflow, OldStartTime will be equal to StartTime -- this is important because the workflow will continue to run every time a particular item is changed, but by taking away the criterion that would cause the workflow to run the second time, you have avoided an endless loop situation.

 

© ASP.net Weblogs or respective owner

Related posts about sharepoint workflow

Related posts about sharepoint