Miscellaneous Debris

Avner Kashtan's Frustrations and Exultations
MOSS Workflows are versioned

I was asked today about MOSS's behavior when workflows are changed midstream. Say I have a document library with a Workflow attached to it, start a few long-running (non-immediate) workflows, then change the workflow before they're completed - will they keep running? Will they use the new workflow or the old, from that point on?

I had hoped for the former, but expected the latter. You can't switch flow in midstream (if you'll pardon my mishmash of similar metaphors), since a newer activity might rely on a variable created by a previous action - one that never took place.

Armed with a burning scientific curiosity and a lack of something to do while the motorway was jammed due to an accident, I set out to check my hypothesis:

 

1) Create a document library with three fields - two text fields and a Yes/No field. The two text fields represent actions taken before and after the change, while the yes/no field is to simulate a long-running workflow that requires other user's interaction:

 

2) Create a simple workflow that updates the Step1 field and then waits around until the Waiting field is set to No:

 

This worked fine, of course - a new document would start the workflow and get its field set to Step1, then wait until I unchecked the Waiting field and then completed. I created another document and left it in the Waiting state.

3) Update the workflow and add another action after waiting - simply setting a value to the post-wait Step2:

 

4) Try it out. I created a new document and verified that Step1 was set before waiting, and Step2 set after waiting. Then I unchecked the Waiting flag on the old document, created with the original workflow.

As expected, Step2 did not get assigned for that document. Despite the fact that the latest version of the workflow had a new action after the Wait, the document was attached to the older version of the workflow, and not the newer. This was also true when I added the second action in a different Workflow Step, rather than a second Action in the same step.

This can be easily seen inside Sharepoint Designer, where we can see that the Workflow's XOML file is just another file stored in just another document library - and like any other document library, it supports file versioning:

 

 

This is a potential cause for confusion - if we have many workflows active and are then required to make a change to it, it's hard to know which workflow is running for which document. The ideal solution would be to complete or terminate all workflows before making a change, but that's hardly a realistic solution for modifying production systems.

Published Tuesday, February 20, 2007 9:04 PM by Avner Kashtan

Filed under: ,

Comments

# A SharePoint Designer Workflow cannot be changed.@ Friday, February 23, 2007 12:18 PM

SharePoint Designer saves the workflow files, but it is compiled only when it is started for the first time. After that point - modifying the XOML will have no affect. The workflow is already compiled and cannot be changed.

Please refer to this article, which contains some considerations and limitations when using SharePoint Designer:

http://msdn2.microsoft.com/en-us/library/ms414204.aspx

Dor.

Dor Rotman

# re: MOSS Workflows are versioned@ Tuesday, June 17, 2008 3:50 AM

I would like to change the version of document in the code?

for example minor version to major version when user is checking in the document and my checkin event handler is executed.?

i hope the code should be written before item.SystemUpdate(false)?

Labhesh Shrimali

Leave a Comment

(required) 
(required) 
(optional)
(required)