Skip to main content

Workflow history deleted in 60 days

By default, WSS3.0 automatically deletes workflow history after 60 days. The purge doesn't technically delete the history - but it deletes the association that ties the document to the workflow history. It also deletes any tasks that were created by the workflow.

This is for performance considerations, courtesy of the Workflow Auto Cleanup timer job in the config section.

Three options to consider:

  • Disable the Workflow Auto Cleanup timer job completely. (Please note that this might have serious performance implications, and should be planned carefully)

  • Include a specific xml tag in your workflow feature.xml file that controls the number of days retained for the workflow history (max days = 9999)
  • Run a job nightly to force all the workflow history retention settings to a certain number of days (max days = 9999)


To set the time schedule for when the scan will occur to delete workflow data for the Web application, http://test, use the following syntax:

stsadm -o setproperty -pn job-workflow-autoclean -pv "daily at 15:00:00" -url http://test

To view the current setting of the job-workflow-autoclean property, use the following syntax:

stsadm -o getproperty -pn job-workflow-autoclean -url http://test

  • You can modify this setting using the SharePoint object model - as Robert's postings suggest take a look at the SPWorkflowAssociation.AutoCleanupdays property. Take a look at the next code sample
    using (SPSite sitecollection = new SPSite("http://moss:99"))
    {using(SPWeb site = sitecollection.OpenWeb("/demo")){ SPWorkflowAssociation _assoc = null; SPList list = site.Lists["Shared documents"]; foreach (SPWorkflowAssociation assoc in list.WorkflowAssociations) { if (assoc.Name == "WFDemo") { _assoc = assoc; _assoc.AutoCleanupDays = 2; } } list.UpdateWorkflowAssociation(_assoc); list.Update();
    }
    }

Comments

Popular posts from this blog

How to get SPUser or SPGroup from Person or Group field

You have person or group field in SharePoint list and you want to programmatically get the user or person. The below code to gets SPUser from User or Group field in the list when multiple choice and Groups are not allowed in the field: //get SPUser SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users"); SPFieldUserValue userFieldValue = (SPFieldUserValue)userField.GetFieldValue(item["Users"].ToString()); SPUser user = userFieldValue.User; This part of code would help you to get SPUser when multiple choice is allowed and groups are not allowed: //Multiple choices are allowed SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users"); SPFieldUserValueCollection userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Users"].ToString()); foreach (SPFieldUserValue userFieldValue in userFieldValueCollection) {     Console.WriteLine("     " + userFieldValue.User.LoginName); } And when group...

SharePoint publishing page scheduling

In SharePoint 2010 publishing enabled team site collection is not showing schedule button in publish ribbon. Solution: Here is how to enable it  though the UI: Locate the SharePoint Server Web site on which you want to enable content approval and item scheduling. Click  Site Actions , click  Site Settings , and then click  Modify Pages Library Settings . Under  General Settings , click  Versioning Settings . Click  Yes  next to  Content Approval , and then click  OK . Click  Manage item scheduling .   Click to enable the  Enable scheduling of items in this list  check box, and then click  OK .

Changing Content Type Hub URL

Change the Hub URL through powershell by using: Set-SPMetadataServiceApplication -Identity " " -HubURI " " For Ex: Set-SPMetadataServiceApplication -Identity "Managed Metadata Service" -HubURI "http://contenttype.Domain.Com" When you try to do this you get this rather scary message: This is SharePoint telling you that this is a major thing so be careful! Essentially all your content types that you have published out will be removed if they can, and you have to republish all of your content types out again which can cause some issue.