Freigeben über


How to modify retention duration for Workflow Instances completed in Workflow Manager

Workflow Manager implements several System workflows to make sure that WFM databases are working healthy.

By default, 'Completed' and 'Terminated' workflow instances are purged from “WFInstanceManagementDB”  database after 30:00:00:00 days (DD:HH:MM:SS ). If you need to modify that default behavior, you should execute below steps:

a)      Open a WFM PowerShell command.

b)      Execute below powershell cmdlet. Please keep in mind that increasing excessively the retention windows time for completed workflow Instances might cause a performance degradation on Workflow Databases.

Set-WFServiceConfiguration -ServiceUri <Workflow Management WebSite URI> -name WorkflowServiceInstanceRecordRetentionDuration -value <DD:HH:MM:SS>

Note: That change will apply to all new Workflow instances executed from that moment on. All existing workflow will be purged at the time specified on “Expiration” column ([WFInstanceManagementDB].[dbo].[Instances])

c)      To verify that the value has been changed properly, execute next command:

Get-WFServiceConfiguration -ServiceUri <Workflow Management WebSite URI> -name WorkflowServiceInstanceRecordRetentionDuration

 d)      Restart WFM services so that the change takes effect: Open a Workflow Manager Powershell command and execute "Stop-WFHost" and then "Start-WFHost" in every WFM server.

 

If you have a SharePoint 2013 connected with Workflow Manager, you should define the same retention period cleanup in both Workflow Manager (WorkflowServiceInstanceRecordRetentionDuration setting) and SharePoint (Timer job "Workflow Auto Cleanup"). Otherwise, SharePoint will not be completely aligned with the information stored at Workflow Manager Database, and you might get below error in SharePoint when trying to see Workflow execution history:

w3wp.exe   (0x8A70)        0xB348 SharePoint   Foundation             Runtime            Unexpected       Microsoft.SharePoint.SPException: We can't find that workflow.    at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WrkStatPage.OnLoad(EventArgse)     at
System.Web.UI.Control.LoadRecursive()     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) 

Hope it helps!!

Comments

  • Anonymous
    April 15, 2015
    Hi Felipe, can you tell me, how I can change this retention peroid cleanup in both Workflow Manager? For the WF 2013 I get the cmdlet from your post, but with the other WFM I have no idea :-). Maybe you can help me! Regards, Christian

  • Anonymous
    September 25, 2015
    Dear Felipe, Thanks for information, i can't find more information about WorkflowService InstanceRecordRetention Duration, ¿can you tell me what keyword have to use in google? I have problem with Audit in my company, because workflows disappeared and I don't have a technical grounds in this regard. How we can turn off the retention? because we need all the information. We have Workflow Manager 1.0 and we develop a approval workflow of SP 2013.