Freigeben über


SharePoint Workflow Auto Cleanup

I am not sure if this blog is really needed/helpful for someone or not, but we keep getting cases about workflow tasks being deleted, vanished, or deleted. Also, workflow status is gone!

 

For SharePoint 2010 workflows (on SharePoint 2010/2013/2016)

Firstly, you should have known that we have SharePoint 2010 workflows on SharePoint 2013 and SharePoint 2016 which run by the SharePoint timer job and not handled by the fancy workflow manager. If you are still not sure what I am talking about, check the below screenshot from SharePoint 2013 site.

What may happen that suddenly you will find that the completed/cancelled workflow instances are gone. In other words, you will find the workflow status column is empty as shown below:

If you are sure that the workflow status was there, then this has been certainly deleted by the timer job Workflow Auto Cleanup. The job runs daily to permanently deletes workflow instancesand related tasksthat still exist 60 days (default value) 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, as shown above. Therefore, if you access the workflow history list, you will find your workflow history records there, but bear in mind that the workflow history list is hidden; so, you have to access it by a direct URL.

 

If needed, you can disable the Workflow Auto Cleanup job, if you want to keep workflow data available longer. However, this is not recommended, as with any SharePoint list, as the workflow history and task lists grow in size, site performance may be compromised. If you are concerned about the size of these lists, keep the Workflow Auto Cleanup job enabled.

Reference: https://technet.microsoft.com/en-us/library/ee662522(v=office.14).aspx

 

Disabling this timer job is not the only solution here, as you can increase the workflow instances/tasks retention by increasing the property SPWorkflowAssociation.AutoCleanupDays. The complete script can be found here https://blogs.msdn.microsoft.com/nishand/2007/09/11/changing-the-spworkflowassociation-autocleanupdays-property/

 

SharePoint 2013 Workflows

The situation for SharePoint 2013 workflows is different, as the workflow instances exist on the workflow manager database not on the SharePoint content database. Therefore, the timer job "Workflow Auto Cleanup" won't delete the workflow instances, but the workflow manager will :). How will this happen? And what's the retention for this?

 

Actually, my colleague Felipe documented this here https://blogs.msdn.microsoft.com/feseca/2014/11/13/how-to-modify-retention-duration-for-workflow-instances-completed-in-workflow-manager/; so, for SharePoint 2013 workflows you should consider both settings: Workflow Manager setting, and the Workflow Auto Cleanup timer job. The workflow instances deletion will be done by the Workflow Manager from the workflow manager database, and the workflow status link on SharePoint will be deleted by the timer job.

Comments

  • Anonymous
    May 23, 2018
    I have tried to set the AutoCleanupDays property to 1 Days, 2 Days and 3 Days and created several items accordingly and ensured some are Completed, Cancelled and In Progress, workflow states.I have further checked Workflow Auto Cleanup is running daily and also using PowerShell command checked AutoCleanupDays for the list where workflow instances are running.To check if AutoCleanupDays property is working or not, I waited for three days but for all the items' task history are still showing. No luck.
    • Anonymous
      May 29, 2018
      Hi Mukeshks,The cleanup timer job will only delete the workflow tasks, and instances, and won't delete the workflow history items. To force this to 1, 2, or 3 days you need to modify the workflow template AutoCleanupDays, which I believe you already did, as documented here https://gallery.technet.microsoft.com/office/Modify-AutoCleanupDays-34a6d1f8. However, this is for SharePoint 2010 workflows. For SharePoint 2013 workflows, please adjust the AutoCleanupDays interval using the Workflow Manager as mentioned here in the article.Hope this helps