Loading...

Thursday, November 12, 2009

How to check if Workflow is already Running and to Avoid Error Exception from HRESULT: 0×8102009B

1: public static bool IsWorkflowRunning(SPListItem item, Guid baseID)
2: {
3: bool isRunning = false;
4:
5: SPWorkflowCollection workflowCol = item.Workflows;
6:
7: var query = from SPWorkflow work in item.Workflows
8: where work.ParentAssociation.BaseId == baseID && (work.InternalState & SPWorkflowState.Running) == SPWorkflowState.Running
9: select work;
10:
11: if (query.Count() > 0)
12: {
13: isRunning = true;
14: }
15:
16: return isRunning;
17: }