Posts

Showing posts from February, 2013

Get all the WorkflowTask associated with a ListItem

Sometimes, we need to access all the Task associated with an SPListItem for a particular workflow. Following quick code is helpful. //using the namespace using Microsoft.SharePoint.Workflow; SPSecurity.RunWithElevatedPrivileges(delegate                     {                         using(SPSite site = new SPSite(SPContext.Current.Web.Url))                         {                             using (SPWeb web = site.OpenWeb())                             {                                 SPList lsPM = web.Lists["MyList"];                                 SPListItem lstMyList =   lsPM.GetItemById(IDOfTheListItem);                                                                  SPWorkflowFilter filter = new SPWorkflowFilter();                                //Filter task based on the Workflow Status                                filter.InclusiveFilterStates = SPWorkflowState.Running;                                 SPWorkflowTaskCollection workTaskColl = we