SharePoint object model updates not triggering workflow

A situation I have observed a number of times while working with the SharePoint object model is that workflows don’t appear to be triggered on update calls.

In the past I have worked around this issue by simply adding some code to loop through the registered workflow items and manually triggering them which has always solved the problem.

I have read recently that the reason the workflow fails to run is due to it being run on a separate thread and that quitting the web app/console app before the asynchronous workflow threads have finished causes them to abort and from the end users perspective the workflow appears not to have run.  This is a known bug in SharePoint but there are a number of workarounds so it’s not considered a show stopper.

It is however possible to work around this limitation by calling SPSite.WorkFlowManager.Dispose() after the item update.  This will wait for the workflow threads to complete before exiting.

Some useful links for further information:
http://blogs.msdn.com/b/malag/archive/2008/07/11/splistitem-update-not-starting-workflow.aspx
https://blogs.blackmarble.co.uk/blogs/rhepworth/archive/2008/07/14/workflow-and-sql-error-update.aspx

Advertisements
This entry was posted in .Net, C#, MOSS, SharePoint, SharePoint 2010, Workflow, Workflow and tagged , , , , , . Bookmark the permalink.

One Response to SharePoint object model updates not triggering workflow

  1. Damian says:

    Calling .Dispose() did not work for me. What do you mean by “looping through the regsitered workflow items and manually triggering…” Any help would be greatly appreciated.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s