Jaa


Changing the SPWorkflowAssociation.AutoCleanupDays property

By default the SPWorkflowAssociation.AutoCleanupDays property value is set to ‘60’ days, to set this property we need to call the SPList.UpdateWorkflowAssociation(SPWorkflowAssociation) function, SPWeb.Update() won’t work here.

 

    1: SPSite site = new SPSite("<https://nishandv3:100/sites/DevSite/>");
    2: SPWeb web = site.OpenWeb();
    3: SPWorkflowTemplateCollection collection = web.WorkflowTemplates;
    4: SPList list = web.Lists["Shared Documents"];
    5: SPWorkflowAssociation _asso = null;
    6: foreach (SPWorkflowAssociation asso in list.WorkflowAssociations)
    7: {
    8: if (asso.Name == "Approval")
    9: {
   10: asso.AutoCleanupDays = 100;
   11: _asso = asso;
   12: }
   13: }
   14: list.UpdateWorkflowAssociation(_asso); 

 

Hope this works for you!

Comments

  • Anonymous
    September 10, 2007
    PingBack from http://msdnrss.thecoderblogs.com/2007/09/10/changing-the-spworkflowassociationautocleanupdays-property/

  • Anonymous
    December 04, 2011
    Hi Is it possible create small tool ? I am not developer so could not use this code :(

  • Anonymous
    December 04, 2011
    Please check blogs.tamtam.nl/.../SharePoint+Worflow+History+Lost.aspx There is already prepared tool, just download and run

  • Anonymous
    September 19, 2013
    Great information. Had the request by a customer today. /greetings Stefan

  • Anonymous
    December 10, 2013
    fgsdfgfgsdddddddddddddddddddddgretretre

  • Anonymous
    April 14, 2015
    I know this is an old post, but has anyone seen an adverse effect to making this change?  I have a customer who wants to set this selectively to maybe up to 7 years.  Just wondering what I am not thinking of that may make that a bad idea.  It would not be for every workflow, but is there still a reason to NOT do it for any workflow?  Thanks.