SPWorkflowCollection on SPListItem is always empty

Posted by armannvg on Stack Overflow See other posts from Stack Overflow or by armannvg
Published on 2010-04-10T13:00:54Z Indexed on 2010/04/10 13:03 UTC
Read the original article Hit count: 277

Hi

I'm having a problem relating to Sharepoint workflows and the associated task list.

I have 2 custom workflows that we created for our product. They both use the same Task list that has a custom content type that inherits from the Task content type.

Now I have a case where a running workflow has been deleted via the list has been deleted or the document, this results in orphaned tasks.

I want to overwrite the Task lists OnDeleting event, so that users can cleanup their tasks so that it won't contain unneccessary orphaned tasks. So my item deleting looks like this

public override void ItemDeleting(SPItemEventProperties properties)
{
   SPListItem currentListItem = properties.ListItem;
}

The problem is that when I go into debug mode and check the currentListItem.Workflows.Count field then it's always 0. It doesn't matter which workflow I initiate or what task i look at, the SPWorkflowCollection returned is always empty :(

I was wondering if this might be related to a bug in our custom workflow where it's not wired up properly (but it finishes correctly and tasks are deleted when a workflow is terminated) or am I looking at this the wrong way ?

© Stack Overflow or respective owner

Related posts about wss-3.0

Related posts about wss