Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We have workflow which enables creator of list item to edit it later. Is it possible to associate workflow with certain list templates, so when user creates new instance of such list, workflow is there and does it job?

share|improve this question

2 Answers 2

In SharePoint 2010 you can use SPListEventReceiver. This class contains handler to perform actions on ListAdded event. In this event you can retrieve list template from current list and compare it with needed template, if the tamplates are equal you can assigne the workflow to this list by code.

SPWorkflowAssociation workflowAssociation = SPWorkflowAssociation.CreateListAssociation(workflowTemplate, associationName, taskList, historyList);
workflowAssociation.AllowManual = true;
workflowAssociation.AutoStartChange = false;
workflowAssociation.AutoStartCreate = false;
workflowAssociation.AssociationData = associationData;
list.WorkflowAssociations.Add(workflowAssociation);
workflowAssociation.Enabled = true;
share|improve this answer

you can use this tool to associated event handlers with a list.

http://spstipsutilitypack.codeplex.com/

Good luck.

share|improve this answer

Your Answer

 
discard

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.