Geeks With Blogs

News invisible hit counter View My Stats
Technical Speaking


Problem Details:

We have created a custom reusable workflow and added with a list on which a workflow (custom workflow) is to start automatically when the item is created. It works great when I add a new item to the list through the SharePoint UI it starts and completes as expected.

We want the list item to be added programmatically, using the SharePoint object model. And when I do this and then look at the list, the workflow hasn't started automatically.


My SharePoint Environment:

  • SP 2010 Ent (Build Version 14.0.4762.1000)
  • SPD 2010 Workflow

So, It can happen if yours Server Farm Version is

SharePoint Server 2010 RTM – Build Version 14.0.4762.1000  (my case)

or below

Build Version 14.0.6029.1000


The problem can be solved easily if you upgrade the Server Farm to Build Version 14.0.6029.1000. because the same scenario is working for me in Another Server where Build Version is 14.0.6029.1000. It means this is a bug of Initial Product Version (Exactly I don’t know when it is solved after 14.0.6029.1000).

But if you are unable to Upgrade Farm due to some other dependency then Start Workflow Manually. I am having the same problem for adding List Item from custom web part. Workflow doesn't Auto-Start when i add new Item Pragmatically and I cannot Update Farm to Build Version 14.0.6029.1000 due to others dependency.

Initially I used the following code to start workflow pragmatically

private static void StartWorkflow(SPListItem listItem, string workflowName)
    // Get the workflow by name that's associated with the list item
    SPWorkflowAssociation wfAssoc = listItem.ParentList.WorkflowAssociations.GetAssociationByName(workflowName, System.Globalization.CultureInfo.CurrentCulture);
    // Start the workflow
    listItem.Web.Site.WorkflowManager.StartWorkflow(listItem, wfAssoc, wfAssoc.AssociationData, true);

But First time it works but from the next time it shows the following error:

How to solve:

Finally I have solved my problem in the following way:

I have change the code to Start Workflow which executes faster that the previous one

public void StartWorkflow(SPListItem listItem, SPSite spSite, string wfName)
  SPList parentList = listItem.ParentList;
  SPWorkflowAssociationCollection associationCollection = parentList.WorkflowAssociations;
  foreach (SPWorkflowAssociation association in associationCollection)
    if (association.Name == wfName)
       association.AutoStartChange = true;
       association.AutoStartCreate = false;
       association.AssociationData = string.Empty;
       spSite.WorkflowManager.StartWorkflow(listItem, association, association.AssociationData);

For more Details please read

Then i called it from Entry From "Save" Button instead of Event Receiver
currentWeb.AllowUnsafeUpdates = true;

call StartWorkflow(...);

//This has to be after start workflow otherwise you will face another Error "Save Conflict.\n\nYour changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes."

currentWeb.AllowUnsafeUpdates = false;

Hope this will help you!!

Related Error:

Posted on Thursday, January 31, 2013 4:05 PM SharePoint 2010 | Back to top

Comments on this post: SPD Workflow Doesn’t Auto Start for List Item created programmatically (SP 2010 RTM Bug)

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © MJ Ferdous | Powered by: