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

I have read, that every now and then the "Workflow Auto Cleanup" job runs and cleans old workflow instances which are older than 60 days are deleted (or something along the lines).

I have a simple Visual Studio workflow attached to a list and it is running on let's say 5 items.

When I delete 4 of these items, the Workflow Status page of the list WrkSetng.aspx still displays 5 instances of my workflow, even though I deleted 4 list items (via the normal UI - no code involved). I atually have never bothered about the number of workflow instaces, but I have several thousand workflow instances running, so if the old ones don't get deleted automatically I might run into a problem.

So my question is: Do I have to delete each workflow instance (including workflow history etc.) manually from the list item, e.g. by using spSite.WorkflowManager.RemoveWorkflowFromListItem(myWorkflow) or do I just have to wait the 60 days and Sharepoint takes care of the rest?

I even tried running the "Workflow Auto Cleanup" job from the Central administration via Run Now, but it didn't seem to do anything - the number of workflow instances as reported by the settings page stayed at 5.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

By default, you just have to wait the 60 days. According to the article you linked to on TechNet:

By default, Microsoft SharePoint Foundation 2010 runs a daily Workflow Auto Cleanup job to permanently delete workflow instances and related task entries that still exist 60 days after a workflow is completed or canceled. Workflow history items themselves are not deleted, but the entry point to view them on the status page for a particular instance of a workflow will no longer be available.

(Note this is the same for WSS 3.0 / SP 2007).

If you want more control over this, set the AutoCleanupDays property on the SPWorkflowAssociation class (here's an example).

Finally, if you want to delete the workflow history items themselves, check out the Cleanup Workflow History tool provided by an MS partner.

I'm not sure how much of an issue it really is having thousands of history items lying around - provided there's not many queries being run on them during business hours. Perhaps running that many workflows at once will cause you more of an issue first!

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.