SPListItem.Workflows also returns completed workflows

I needed to retrieve all the running workflows for a list item. I tried SPListItem.Workflows and according to MSDN this should give me what I need. It however doesn’t – I found that it also includes completed workflow instances.

I found that I can use the SPWorkflowManager.GetItemActiveWorkflows() method instead to achieve what I needed.

The MSDN documentation for SPListItem.Workflows says:

Gets the collection of the workflow objects that represent instances of the item workflows that are currently running, but does not get the workflow associations.

The MSDN documentation for SPWorkflowManager.GetItemActiveWorkflows() says:

Returns a collection of the workflow instances currently running on the specified list item.

One would expect that they would give the same results – it however seems that the former doesn’t work as documented.

Advertisements

About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in SharePoint 2010, Workflow. Bookmark the permalink.

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