Thursday, July 26, 2007

Delete Files with Workflow Using Duration

This is just a quick little tidbit.  Out-of-Box workflows in MOSS, unless manually kicked off, require an event to be triggered.  I was trying to figure out a way to automatically delete files from a document library 3 days after they were uploaded.  The doc library was being used strictly as a transfer point and needed to be kept clean.  Thanks to Sean S. for the idea...

So as simple as it is:

1.       Start a new workflow using SharePoint Designer by going to File -> New -> Workflow.

2.       Give the Workflow a name and select the target doc library or list.

3.       Set the start event.  I set mine to automatically start when the item is created or changed.  Click Next.

4.       Enter a name for Step 1 such as `Pause for 3 days'

5.       Do not select a condition because we want it applied to all items.

6.       Under Actions select `Pause for duration'.

7.       Change to 3 days, 0 hours, and 0 minutes.

8.       On the right choose to `Add workflow step'

9.       Once again, give the step a name and no condition.

10.   Select Delete Item under Actions and set it to Current Item.

11.   Click Finish to save the workflow.

NOTE: A good way to test this first is to set the duration to a low count like 1 minute.  Once you are sure it works properly, set it to your desired time frame.


  1. Excellent post. Thank you.

  2. Jeff how can I delete bulk items based on the value of another item? For example a user sends an email with several documents attached (including a PDF) to my doc library. When added each document is assigned a File Reference based on the email subject. If a manager rejects the PDF then I would like for MOSS after 30 days to delete this PDF and all applicable files with the same File Reference.

  3. I know this is quite old but I have a question, I've created the workflow and it works fine, the problem is that I'm receiving the files vie email, and the workflow does not detect those file, only when they are manually uploaded into the SP. Do you know if there's a workaround to solve that?