locked
Information Management Policy to clean up the Workflow History List?

    Question

  • I have several InfoPath 2007 forms (with workflows) that are heavily used in my MOSS 2007 environment, and the some of the Workflow History lists are very large need to be cleaned up.  I'm trying to use an (Expiration) Information Management Policy to delete items in the Workflow History list that are Last Modified + X days , but haven't had much success.  Has anyone else had success doing this?

    Thanks,
    Tim

    Monday, November 15, 2010 7:21 PM

Answers

  • 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 Workflow History lists each night to make sure they stay small.

    Reply to this thread with an email address if you would like a copy of it - I'll send the source code as well.

    Thanks,
    Tim

    • Marked as answer by Tim Mayo Friday, November 26, 2010 11:39 AM
    Friday, November 26, 2010 11:39 AM

All replies

  • Hello Tim,

     

    Built-in expiration setting only allows "Date Occurred" to be specified for the time period. An alternative is to create a calculated column with formula “Modified + X days”, disable workflow history list “Hide from browser” via SharePoint Designer list properties settings and then create a SharePoint Designer workflow that associated with workflow history list and select "Automatically start this workflow when a new item is created" . Try to use “Pause until date” action in that workflow and specify the newly created calculated field for the time.

     

    BTW, SharePoint runs a daily Workflow Auto Cleanup job to permanently delete workflow instances and related task and history entries that still exist 60 days after a workflow is completed or cancelled. For details about Workflow Cleanup Job, please see:

    http://technet.microsoft.com/en-us/library/cc298800(office.12).aspx

     

     

    Hope it helps.

     

    Thanks & Regards.

     

     

    Lily Wu

    TechNet Subscriber Support in forum

    If you have any feedback on our support, please contact tngfb@microsoft.com


    Lily Wu
    Tuesday, November 16, 2010 2:40 AM
  • Thanks for the reply Lily.

    "Built-in expiration setting only allows "Date Occurred" to be specified for the time period."
    I don't think that is correct.  On a new install, at the top-level site, Site Settings > Modify Site Settings > Site Collection Policies > Create > Enable Expiration.  I see 2 options: Last Modified + X days/months/years or Created Date + X days/months/years.  I create the policy there and then apply it at the list level.

    "BTW, SharePoint runs a daily Workflow Auto Cleanup job to permanently delete workflow instances..."
    I know that's not correct - in the link you provided, look for "
    Workflow history items themselves are not deleted".  The Workflow Auto Cleanup timer job does run daily, but it only deletes workflow associations (which also deletes tasks).  It does not delete the items in the Workflow History list.


    I'm hoping to get feedback from someone who has tried (successfully or not) to clean up the Workflow History list.

    Tuesday, November 16, 2010 3:51 AM
  • Thanks for correcting me, Tim. I forgot the policy at site collection level.

    What about using SPD workflow to clean up the workflow history list?

     

    Thanks & Regards.


    Lily Wu
    Tuesday, November 16, 2010 5:42 AM
  • Hi Lily,

    If I used a workflow to cleanup the Workflow History list, that would create new items in the list I'm trying to clean up.

    Thanks,
    Tim

    Tuesday, November 16, 2010 12:24 PM
  • 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 Workflow History lists each night to make sure they stay small.

    Reply to this thread with an email address if you would like a copy of it - I'll send the source code as well.

    Thanks,
    Tim

    • Marked as answer by Tim Mayo Friday, November 26, 2010 11:39 AM
    Friday, November 26, 2010 11:39 AM
  • You can download the console application and source code here: http://code.msdn.microsoft.com/CleanWorkflowHistory
    Friday, January 28, 2011 6:09 PM