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?
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;
you can use this tool to associated event handlers with a list.