1

We have one sharepoint 2013 declarative workflow associated on one list. Now If I goes to workflow details page of any list item which is more than 30 days ago, Then no any running/completed workflows are there.

I googled about it & found that sharepoint timer job will delete workflow association after 60 days of completion. But in our environment we cant able to see completed workflow instances after 30 days.

Does Completed workflow instances automatically cleaned up after 30 days in sharepoint 2013 ???

Please help.

2

By default it is 60 days but one can change that retention to different numbers.

0

try the following to set the AutoCleanupDays for all workflow associations on a list.

# Sample Usage 
# Set-SPListWorkflowAssocationCleanup -WebUrl "http://intranet" -ListName "Shared Documents" -CleanupDays 365 -ReportOnly:$false 


function Set-SPListWorkflowAssocationCleanup { 
    param ( 
        [string] $WebUrl = $(Read-Host -prompt "Enter a Url"), 
        [string] $ListName = $(Read-Host -prompt "Enter a List Name"), 
        [int32] $CleanupDays = $(Read-Host -prompt "Enter the number of Cleanup Days"), 
        [switch] $ReportOnly = $true 
         )         

     $web = Get-SPWeb $WebUrl; 
     if ($web -eq $null) { 
         Write-Error -message "Error: Web Not Found" -category InvalidArgument 
     } else { 
         $list = $web.Lists[$ListName]; 
         if ($list -eq $null) { 
             Write-Error -message "Error: List Not Found" -category InvalidArgument 
         } else { 
             [Microsoft.SharePoint.Workflow.SPWorkflowAssociation[]] $wfaMods = @(); 
             foreach ($wfa in $list.WorkflowAssociations) { 
                 $message = "Found Workflow Association for " + $wfa.Name + " with AutoCleanupDays set to " + $wfa.AutoCleanupDays 
                 Write-Verbose -message $message -verbose 

                 if ($ReportOnly -eq $false) { 
                     $wfa.AutoCleanupDays = $CleanupDays; 
                     $wfaMods = $wfaMods + $wfa; 
                 } 
             } 

             if ($ReportOnly -eq $false) { 
                 foreach ($wfa in $wfaMods) { 
                     $message = "Setting AutoCleanupDays for " + $wfa.Name + " to " + $CleanupDays 
                     Write-Verbose -message $message -verbose 
                     $list.WorkflowAssociations.Update($wfa); 
                 } 
             } 
         } 
     } 
 } 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.