Saturday, December 20, 2008

SPD Workflow: The changes performed in the workflow are not reflected on the site

A. Introduction: I have recently encountered a very weird problem while working with SPD workflows:
  • Open the workflow's XOML file.
  • Perform some changes to the workflow steps.
  • Click the Finish button, in order to save the changes.
  • Although the changes are saved successfully, the next time the workflow is triggered the old version of the workflow is run. In other words, the changes done to the workflow are not refelected on the site.
B. Unsuccessful Trials: Trial 1:
  • Restart SharePoint Designer.
  • Open the workflow, perform any simple change (e.g. Log To History List) and click Finish.
  • Trigger the workflow -> Changes are not refelected.
Trial 2:
  • Close SharePoint Designer.
  • Open the workflow settings of the list to which the worklfow is attached.
  • Remove all the workflow instances attached to the list.
  • Open SharePoint Designer.
  • Open the workflow, perform any simple change (e.g. Log To History List) and click Finish.
  • Trigger the workflow -> Changes are not refelected.
C. Solutions: This section provides two solutions of the described problem. One of them is how my team has fixed the problem and the other is taken from a colleague of mine who has coincidentally heard about our problem and told us that he has encountered it once and how he has fixed it then. Solution 1:
  • Close SharePoint Designer.
  • Open the workflow settings of the list to which the worklfow is attached.
  • Remove all the previous versions of the workflow instances attached to the list. (Cleanup step)
  • Save the list as a template. NOTE: Select the Include Content checkbox.
  • Delete the list to which the workflow is attached.
  • Create a new list using the saved list template.
  • Open SharePoint Designer.
  • Open the workflow, perform any simple change (e.g. Log To History List) and click Finish.
  • Trigger the workflow -> The changes are refelected correctly.
Solution 2:
  • Close SharePoint Designer.
  • Open the workflow settings of the list to which the worklfow is attached.
  • Remove all the the workflow instances attached to the list, including the current version.
  • Open SharePoint Designer.
  • Create a new workflow on the same list and add any simple condition and any simple action to it.
  • Click Finish, in order to save and publish the new workflow. Note that the new workflow has the files [workflow name].xoml and [workflow name].xoml.rules.
  • Using Notepad, copy the content of the old "xoml" file into the new "xoml" file.
  • Using Notepad, copy the content of the old "xoml.rules" file into the new "xoml.rules" file.
  • Open the new worklfow and quickly go through all the conditions and actions, to make sure that no variables are corrupt. Note: In case you use a Collect Data From User action in your workflow, I recommend that you create a new action and remove the old one.
  • Click Finish, in order to save and publish the new workflow.
  • In case the new workflow is saved properly, delete the old workflow in SPD. This can be done by right-clicking the workflow's name under the Worklfows node, selecting Delete and confriming the deletion when the warning message appears.
  • Finally, trigger the workflow -> The changes are refelected correctly.
D. Source of the problem: There is still a question lying there unanswered, namely What is the cause of this weird SPD behavior? Although the previous section provided a fix, but the more important issue is: How can we avoid this annoying problem in the future? Currently, I do not have the answers to these questions. As soon as I do, I would update the article. Meanwhile, any contributions would be highly appreciated.

6 comments:

Lebanese in KSA said...

Dear Samar,

Thank you for this post, I've used the second solution and it worked perfectly.

Regards,

Samar Hossam said...

I am very happy to know that this post was useful to you.

By the way, I have encountered so many problems while maintaining SPD workflows. Thus, I am currently building my Know How in developing workflows with Visual Studio. I read that its problems are not as much as SPD :)

Tom Molskow said...

Samar,

This is great! You have done a great job documenting this solution to an all too frequent problem - thank you!

Tom Molskow

Obi said...

Nice post. An even easier solution is to clear your PC's cache.
To do so, go to C:\Users\[Username]\ApPData\Local\Microsoft\WebsiteCache and delete everything there. That's what I did and it worked like a breeze.

I found out about it here http://sharedpointing.wordpress.com/2009/09/21/sharepoint-designer-errors-were-found-when-compiling-the-workflow/

Tom Molskow said...

Where would the cache be located in Windows XP?

Anonymous said...

OMIGOODNESS - THANK YOU!!! THIS WAS SO MADDENING!!! The websitecache thing worked. I have been fighting this for two days. I have had several odd issues like this before and I was exhausting all the other odd tricks I had learned. Check in & check out, publish the files, recycle the application pool, restart the server, get rid of all the old versions, and all the permutations of the different ordering in which to perform such tasks, etc etc. I guess I get to add a new one to the bag. I don't know about XP but in windows server 2003 the path is C:\Documents and Settings\[username]\Local Settings\Application Data\Microsoft\WebsiteCache\[siteName]