SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 created a Sharepoint 2010 Sequential Workflow in a Visual Studio 2010 project. But I didn't found a way to associate it to one of my list. Every time I deploy to the site, I have to manually associate it with the good list.

The list is also created in the VS 2010 project.

Is there a way to associate my workflow to a list to be invoked every time an item is created or updated ?


share|improve this question
up vote 1 down vote accepted

If you would like to associate workflow with the specific list when you deploy you solution by VS2010, you can select workflow, choose element property ans set Target List.

share|improve this answer
Thank you, it worked. – Baptiste Wicht Oct 27 '11 at 13:52
SPWorkflowTemplate baseTemplate =                                        currentSite.RootWeb.WorkflowTemplates.GetTemplateByName
                                                ("workflow", CultureInfo.InvariantCulture);
                                        SPWorkflowAssociation workflowAssociation =
                                        workflowAssociation.AllowManual = true;
                                        workflowAssociation.AutoStartChange = false;
                                        workflowAssociation.AutoStartCreate = false;
                                        liste = currentWeb.Lists;
                                        foreach (SPList list in liste)
                                            if (list.ContentTypes[0].Name == "ct")

For adding to a specific content type. For lists should be the same. Good luck !

share|improve this answer
Thank you, but where do I have to put this code if it has to be executed on the deploy of a feature ? – Baptiste Wicht Oct 27 '11 at 13:28
In a feature activated could be placed – user3145 Oct 27 '11 at 13:55

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.