views:

290

answers:

1

I am facing a rather peculiar problem here. We have an OOTB approval workflow, which logs all the workflow history into a workflow history list. This list gets purged every 60 days. To increase this time period for which the workflow history is retained, I googled around and found that I have run this code:

using (SPSite wfSite = new SPSite(siteUrl)) {

using (SPWeb wfWeb = wfSite.OpenWeb(webName))

{

     SPList wfList = wfWeb.Lists[listName];

     SPWorkflowAssociation _wfAssociation = null;

     foreach (SPWorkflowAssociation a in wfList.WorkflowAssociations)

     {

         if("approval 1" == wfAssociationName.ToLowerInvariant())

         {

             a.AutoCleanupDays = newCleanupDays;

             _wfAssociation = a;

             assoCounter++;

         }

         else

         {

             _wfAssociation = a;

         }

     }

     wfList.UpdateWorkflowAssociation(_wfAssociation);

}

}

The code works fine, in the sense that it does not throw any exceptions. So far so good. But my problem now is that I need to test whether my code works. So i set the newCleanupDays variable to 0. But i see that new workflow activities are still getting logged in the workflow history list. I can set the variable to 1, but that would mean waiting an entire day to see if the code works..

Is there any way in which I can test my scenario, so that I can set the autocleanup days to 1, and I dont't have to wait an entire day to see if my code works? Is there any way I can "Fool" the system into thinking that 1 day has elapsed? I tried changing the system time and restarting the server and everything, but it didn't work for me.

+2  A: 

Changing the system time should work, but you are going to have to kick off the timer job that initiates the workflows. Don't restart the server after the time change.

One warning is that SharePoint really really does not like travelling back in time. Any documents that are created in the "future" are going to have issues. So remember to test in a new web site that can be deleted when you roll back to "now".

Nat
Thanks for the answer, how do I kickup the timer job? Will "STSADM -o execadmsvcjobs" do the job?
ashwnacharya
Go to the admin site and set the schedule for the workflow job to be every 5 min should do it
Nat