3

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...

1 Answer 1

0

My understanding is that Workflow history is not reliable (more so if you have multiple independent workflows active against a specific list).

One way to avoid that problem is to consider creating a custom list to store all of your audit type information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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