Skip to main content
< All Articles

How to set up retention and deletion policies for files and folders in SharePoint

Posted on June 1, 2017
SharePoint

Some time ago I published a post around retention and deletion of sites in the SharePoint environment. Today, I want to explain how to set up retention and deletion policies for the actual content (files and folders). Setting up such policies will allow you to adhere to certain regulations within your industry. For example, if you are an accounting firm, you might need to retain clients’ taxes for at least 7 years and then purge them from the SharePoint environment.

NOTE: This article describes the retention options in “classic” SharePoint. Since publishing this post, Microsoft released modern Retention features via the Security and Compliance Center. Please check out this most recent post to learn more.

There are 4 places where you can define Retention Policies in SharePoint:

  1. Site Collection
  2. Content Type
  3. Document Library
  4. Folder

1. How to set Retention Policy for the Site Collection

Policies defined at the Site Collection Level can be later applied to site content types within the site collection. Policies applied at the site collection level serve more as templates that can be manually applied later on (to site content types) as desired by the site owners.

To set up a site collection retention policy, do the following steps:

  1. Navigate to the root of your site collection
  2. Click on Content Type Policy Templates (under Site Collection Administration)Retentionpolicy1
  3. Hit CreateRetentionpolicy2
  4. On the next screen, fill out the details about the policy. The administrative description is for site owners, so they understand the logic for the given policy. Policy statement, on another hand, is for end users and will be displayed to them when they open a document (assuming such policy has been applied to the document via library, content type or folder)retention and deletion policies
  5. Under Retention section, check the Enable Retention box, then click on Add retention stageRetentionpolicy4
  6. On the pop-up that appears, fill out the Event (what will trigger the policy) and the Action (what will happen to the document). There are a few options available, but for the purpose of this example, I specified [Modified Date] + 7 years for the Event and then Move to Recycle Bin for the action. Click OKretention and deletion policies
  7. The policy will now be added to the list, as shown below. Click OK again to save all the changesRetentionpolicy6

That’s all. So at this stage, the policy has been created at the site collection level and can be applied to the site content types on any of the sites in a given site collection! To learn how to do this, keep reading.

2. How to set Retention Policy for the Content Type

In the example above, we created a policy at the site collection level. It does not automatically take effect until applied to the content (via content type, library or folder). In this section, I will demonstrate how to set a policy at the content type level

  1. Navigate to the site where you manage your content types (this could be any site or site collection root again)
  2. Gear Icon > Site Settings
  3. Click on Site Content Types (under Web Designer Galleries)Retentionpolicy7
  4. Navigate to or create a new content type (I explain how to do this in this post)
  5. Click on Information management policy settingsRetentionpolicy8
  6. What you see on the next screen will depend on whether or not you created a site collection policy in above step. If you did not, skip to next step. If you did, you would see a screen that looks like this. It allows you to specify a policy for your content type. You can choose from the following options: None, Define a policy and Use a site collection policy. If you choose Use a site collection policy, you can choose the policy(ies) templates you created at the site collection level in the section above. In our case, we will create a custom site content type policy, so let’s click on Define a policy radio buttonRetentionpolicy15
  7. You will now see a familiar screen. The remaining steps are identical to what we did in the above example, so I will not be repeating them again. You pretty much do the same steps, set your retention policy, triggering event and an action.Retentionpolicy9

That’s all! Once created, this Retention policy is now part of the content type. So any document libraries utilizing this content type will now adhere to the information management policy set (of course if it has been applied and not overwritten, which is what we will cover in the next section).

3. How to set Retention Policy for the Document Library

All right, now we are getting into the weeds. In the previous sections, we created policies, but at the end of the day, all content is stored in document libraries and folders, and that’s where we will apply them.

  1. Navigate to the library where content is stored (any subsite within the site collection)
  2. Click on Information management policy settingsRetentionpolicy10
  3. This next screen is very important. Under Source of retention for this library, you will see that the default setting is Content Types. That means that the library honors the retention policies set within the content types that you added to your document library. Below, you will see all the content types that are part of my document library. In my case, you see Document and Folder (these are default site content types applied to each document library automatically) and the Custom Site Content Type (Financial Documents) I created in the previous step and then applied to my document library. As you can see, it even shows the description we specified before, so it is clear what kind of policies are set for specific content type in the document library.Retentionpolicy11
  4. However, you might want to override those retention policies and set one up at the document library level. For this to occur, under  Source of retention for this library, click Change sourceRetentionpolicy12
  5. On the nex screen, you have a chance to break the inheritance. Essentially, by default, the library honors the policies set at the site content type level. Once you click Library and Folders, the Site Content Type policies are ignored and are overwritten by policies set for the document library. Choose Library and Folders radio button and click OKRetentionpolicy13
  6. You will get a warning message, just click OKRetentionpolicy14
  7. Once changed, your source should say: Library and Folders, just like in image below
    Retentionpolicy16
  8. To configure retention or deletion policy for a document library and folders, click on Change source or configure library scheduleRetentionpolicy17
  9. To set a custom retention policy for a document library, click on Add a retention stage… You will then see a familiar menu (pop-up) where you can set your retention policyRetentionpolicy19
  10. That’s all! You now have a custom retention policy set for this specific document library.

4. How to set Retention Policy for folders

You can also set retention and deletion policies for each folder within a document library as well! Here is how to do this.

  1. When you Change source or configure library schedule to Libraries and Folders using the steps above, you will notice your folder hierarchy on the left-hand-side.
  2. Click on any of the folders on the left-hand side, and then define/add a retention stage as necessary. Click Apply and OKRetentionpolicy20
  3. Once set, you will see a small green wheel/icon appear over the folder name, which means that this folder has a retention policy set for this particular folderRetentionpolicy21
  4. That’s all! You can now use this technique to set custom policies for individual folders within a document library.

Additional and very useful information related to the retention policies

Now that we learned how to create retention policies for various types of content type, I also want to share some additional tips and tricks that I find useful. Here they are.

Disable Library and Folder Based Retention override

Remember, how in the previous step, we were able to override the site content type policy and essentially set up our own, library or folder based policy? What if you want to enforce the site content type policies across the board and prevent users from setting up their own for libraries and folders? You can do that, but you will need to disable the override. In SharePoint Online, by default, the override is enabled. To disable, follow these steps:

  1. Go to the root of the site collection, then Gear Icon > Site Settings
  2. Site Collection Features (under Site Collection Administration)Retentionpolicy22
  3. Navigate to Library and Folder based Retention, then click DeactivateRetentionpolicy23
  4. You will then get a warning message, click on Deactivate this featureRetentionpolicy24
  5. Once deactivated, users will no longer be able to change the source as we did in previous steps, as demonstrated by image below.Retentionpolicy25

File Plan Schedule

Imagine you set up all these retention policies, but now need a quick overview of what policies are set for various documents and folders within a document library. No problem at all, here is what you need to do:

  1. Go to Library Settings, then click on Generate file plan report
    Retentionpolicy26
  2. On next screen, specify where you want to save it (default location is the same document library). Click OKRetentionpolicy27
  3. You can then click to view the report or navigate to the library where you will find it as wellRetentionpolicy28
  4. The Excel output file contains several tabs with various details, but most importantly shows you the different policies set for the library and/or foldersretention and deletion policies

Timer Job

It is very important to note that the actions defined in the retention policies will not necessarily occur on the date scheduled. For example, you may setup a test policy where items are deleted 1 day after last modified date. Do not be surprised that they will still be in their location 1, 2 and even 5 days after. The thing is, in SharePoint Online, there is a timer job that runs on a certain schedule that takes care of all retention policy actions. Sometimes it might take weeks for it to work. In my example, I did the 1-day test, and it took 3 more weeks for items to be moved to the Recycle Bin. The bottom line – it does work, just have to be patient (in SharePoint on-premises you can configure this timer job, but not in SharePoint Online).

About Me

I’m Greg Zelfond, a U.S. based SharePoint consultant, and I provide affordable out-of-the-box SharePoint consulting, training, and configuration assistance to small and medium-sized businesses all over the world.

Need help?