Extending workflow task history

Document created by nintex Expert on Dec 22, 2014
Version 1Show Document
  • View in full screen mode

              Extending workflow task History List

 

By default Nintex workflow task history will clean up the task for every 2 months i.e: 60 days.

If in case user want to extend or reduce the cleanup task history list, then we need to execute the below PowerShell command on any one of the WFE servers.

 

 

#Add-PsSnapin Microsoft.SharePoint.PowerShell

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 = $false

        )

    $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-Host $message;

                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);

                }

}

        }

    }

}

 

Set-SPListWorkflowAssocationCleanup

 

Post executing this script you will get a pop up to enter the Web URL, Nintex workflow task history list name and number days to clean up the task history.

Outcomes