.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Automatically Delete document after 2 days using Retention Policy in SharePoint

Posted By:Jean Paul       Posted Date: July 17, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we will explore a real-life scenario of automatically deleting documents. You can play with other retention policies as well in sharepoint.

In this article we can explore a real world scenario.

ยท Our client needs a document library where users can store some informational documents. The library should cleanup documents which are 2+ days older.

How to achieve this?

We can use Retention Policy which is out-of-the box. The solution should take only less than 5 minutes to implement.

What is Retention Policy?

Retention Policy is an Information Management Strategy in SharePoint. We can set various retaining policies for documents & items.

The policy can be set at the Site Collection level and Library level.

Please follow the steps to undergo our exercise.

Step 1 Create a Temporary Library

Create a new temporary document library & call it as Tempdocs


Step 2 Open Information Management Policy Settings

We are going to set a policy for this library. Open Library Settings > Information management policy settings page from the link below.


You will get the following page.


Step 3 Edit Document Content Type retention policy

Click on the Document link from the list above. In the appearing page, choose Define a policy as shown below.


Step 4 Enter Policy Details

In the appearing page enter the details about the policy.


Step 5 Add Retention State

We are actually creating a retention policy. (act of retaining)

So click on the Enable retention check box & then on the Add retentions stage link as shown below.


Step 6 Enter Retention Details

In the appearing dialog, enter the retention details.


The retention have 2 items:

1. Event

2. Action

When the Created date passes +2 days the event is triggered & the action would be Delete the document.

Click Ok to save the dialog. When the dialog box returns, click Ok in the retention policy page as well.


Now we are ready with our Retention Policy of deleting documents which exceeded 2 days from date of creation.

Step 7 Testing the Policy

For testing the policy, add a document to the library.


Step 9 Change Date

Open the date/time settings & make the date +3 days from today.


Step 8 Execute Timer Jobs

Following are the 2 timer jobs responsible for doing the tagging & deleting of document.

1. Information management policy

2. Expiration management policy


These timer jobs may be scheduled for running daily or weekly. As we cannot wait that much time for testing, we prefer to run them immediately.

Open Central Administration > Monitoring > Check job status > Job Definitions


Locate the above timer jobs, click to open it & choose the Run Now option. Please execute in the order described below.




Open each timer job & click the Run Now button.


Please note that there will be multiple timer jobs with the same name, ensure you execute the one corresponding to your web application.

Step 9 Verify the Document

Now revisit the document library & you can see the document uploaded disappeared.. It got deleted!


This makes sure that the Retention policy is working.


Please note that, additional to Retention Policy, we can have Auditing, Barcode and Label policies.


Additional to that we can use more Events & Actions:

1. Events like Created date > 1 year, Modified date greater than 1 year & so

2. Actions like Move to recycle bin, Declare as record etc.




In this article we have explored a real-life scenario of automatically deleting documents. You can play with other retention policies as well.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend