none
How to delete the contents of the Workflow History List

    Question

  • I'm trying to purge the contents of the workflow history list which has thousands of comments added by the some workflows (I will fix the workflows later!). I'm worried that the huge number of entries in this list is slowing down the site performance. At this stage I do not need any of these entries for any audting or other purpose. I'm not sure of the best way to go about this.

    My current strategy is to rely on the workflow autoclean sp timer job, after first running some code to set the AutoCleanupDays property of the SPWorkflowAssociation. I'm hoping that once I have run this on all the document libraries in my site where workflows have been run I will then be able to delete the Workflow History list using the Sharepoint Web UI "Delete this list" hyperlink.

    When I do this at them moment I get an error as below:

     

    Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))   at Microsoft.SharePoint.Library.SPRequestInternalClass.DeleteList(String bstrUrl, String bstrListName, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId)
       at Microsoft.SharePoint.Library.SPRequest.DeleteList(String bstrUrl, String bstrListName, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId)

    If anyone can confirm whether this approach will work or if there is a better way to do this I will be very happy!

    Wednesday, October 20, 2010 12:04 AM

All replies

  • Hi,

     

    You can go to the workflow history list through http://sharepointsite/lists/workflow history  and then delete it like deleting a common list.

     

    But I don’t suggest you to do it and you can just change the timer job schedule to run it more frequently.

     

    Hope it is helpful!


    Seven
    • Marked as answer by Seven M Thursday, October 28, 2010 3:26 AM
    • Unmarked as answer by Mike Walsh FIN Friday, January 28, 2011 11:07 PM
    Tuesday, October 26, 2010 8:42 AM
  •  

    But I don’t suggest you to do it and you can just change the timer job schedule to run it more frequently.

     


    That is not true.  The "Workflow Auto Cleanup " timer job in SharePoint only deletes the workflow associations.  It does not delete items in the Workflow History list.

    That timer job uses the AutoCleanupDays property to determine how old the associations should be before it deletes them.

    Microsoft leaves it up to us to actually delete the items in the Workflow History list...

    Friday, November 12, 2010 7:45 PM
  • ThePrior21,

    I had the same problem with the workflow history lists getting too large.  After doing some digging, I found out that the timer job (Workflow Auto Cleanup) only deletes the association between the item in a list (Document Library / Form Library / etc.) & it's associated item in the Workflow History list.  It does not delete items from the Workflow History list.

    I ended up writing a console application that deletes the items from the Workflow History list, and then deletes them from the Recycle Bin.  First I use it to get the list to a manageable size, then I run it on individual lists each night to make sure they stay small.

    Thanks,
    Tim

    Moderator Note: The propose as answer forum is for proposing the good answers of other people. It is not for self-proposing. The forums should not be filled with requests for e-mail. If you want to offer source code, put it on a web site and post the url in your post.

    • Proposed as answer by Tim Mayo Friday, November 26, 2010 11:37 AM
    • Unproposed as answer by Mike Walsh FIN Friday, January 21, 2011 6:24 PM
    • Edited by Mike Walsh FIN Friday, January 21, 2011 6:27 PM Moderator Note added. and request for e-mail addresses removed.
    Thursday, November 25, 2010 5:03 PM
  • You can download the console application and source code here: http://code.msdn.microsoft.com/CleanWorkflowHistory
    • Marked as answer by Mike Walsh FIN Friday, January 28, 2011 11:07 PM
    • Unmarked as answer by Mike Walsh FIN Thursday, February 03, 2011 2:46 PM
    Friday, January 28, 2011 6:08 PM
  • Tim,

    This link doesn't work. Do you have a new working one ?

    (I have unlocked the thread for now - I will lock it again if we get a new working link so people please don't add any new questions in this otherwise old thread!.)

    Moderator

     


    SP 2010 "FAQ" (mainly useful links): http://wssv4faq.mindsharp.com/default.aspx
    WSS3/MOSS FAQ (FAQ and Links) http://wssv3faq.mindsharp.com/default.aspx
    Both also have links to extensive book lists and to (free) on-line chapters
    Thursday, February 03, 2011 2:47 PM
  • Thanks for letting me know Mike - it should work now.  They are migrating projects to the beta version of the code.msdn.microsoft.com site.

    http://code.msdn.microsoft.com/CleanWorkflowHistory (this should redirect to the beta site)

    http://beta.code.msdn.microsoft.com/Cleanup-Workflow-History-cee6e75e (direct link to the beta site, probably temporary)

    Thanks,
    Tim

    Thursday, February 03, 2011 4:26 PM
  • Hi there,

    If you have enough privilege on the WF history list (I bet you do since you are asking to purge the entries), can you try:

    'Action > Edit in Datasheet' and highlight the rows to delete? Might take some time for commitment depending on the number of rows.

    That's how I usually do it.

    Thursday, February 03, 2011 4:49 PM
  • Enable a retention policy on the list using the Information management policy settings for the list.

    No code solution :-)

    • Proposed as answer by DaBill Friday, November 08, 2013 8:30 AM
    • Unproposed as answer by Steven AndrewsEditor Sunday, December 01, 2013 12:20 AM
    Friday, November 01, 2013 10:54 AM
  • We've tried applying a retention policy for expiration of Workflow list items based on Date Occured and Created Date but neither seem to delete the items.  After that have run both the Info Mgmt and Expiration Policy timer jobs.  What's your trick?

    Allison Bates

    Tuesday, November 26, 2013 3:41 PM