SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom sharepoint (2007) list (named testlist) on which I attached a test workflow (built with sharepoint designer 2007 and named testwf), which only task defined in the 'Actions' section at 'Step 1' is to wait until april 2014. When I add a new item to the testlist the testwf will start and, when I switch to the grid view, the item has the field "testwf" as running.

Now I need to access the workflow associated with the item and then "complete" this task via code by changing its status but, using the following code, I always get the item.Tasks list empty (but I can see that the internal variable m_allTaskListTasks has 1 element).

        using (SPSite site = new SPSite("http://mysp"))
            site.AllowUnsafeUpdates = true;
            SPWeb web = site.OpenWeb();
            web.AllowUnsafeUpdates = true;

            foreach (SPList list in web.Lists)
                if (list.Title != "testlist") continue;
                foreach (SPListItem item in list.Items)
                    item.Web.AllowUnsafeUpdates = true;
                    if(item.Tasks.Count > 0) 
                       //do work

Maybe I'm missing something...

share|improve this question
Need an answer for this... anyone?? – Muhammedh Sep 27 '14 at 9:29
I have the same problem in SharePoint 2013. I also see the same problem for SPListItem.Workflows - nothing returned. Any help? – Submits Jan 5 '15 at 15:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.