I have created a feature. In the FeatureActivated event I am creating some lists. I am then trying to attach a custom workflow to one of the created lists. However when I do this the workflow history list that I create disappears.
Here is the code that associates the workflow to the list.
var workflowAssociation = SPWorkflowAssociation.CreateListAssociation(workflowTemplate[id], "Submit For Approval", taskList, historyList);
workflowAssociation.AllowManual = true;
workflowAssociation.AutoStartChange = false;
workflowAssociation.AutoStartCreate = false;
underApprovalList.WorkflowAssociations.Add(workflowAssociation);
workflowAssociation.Enabled = true;
Where:
- workflowTemplate[id] is web.WorkflowTemplates[id of template]
- taskList non null splist created with SPListTemplateType.Tasks
- historyList non null splist created with WorkflowHistory
- underApprovalListnon null splist of SPListTemplateType.DocumentLibrary type
When I comment this code out of the event the historyList is created. When I do not comment it out it is not.
Update
The history list is there if you navigate by URl rather than look for it. So the problem seems to be that the workflowAssociation is not working...