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:
- Site Collection
- Content Type
- Document Library
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:
- Navigate to the root of your site collection
- Click on Content Type Policy Templates (under Site Collection Administration)
- Hit Create
- 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)
- Under Retention section, check the Enable Retention box, then click on Add retention stage
- 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 OK
- The policy will now be added to the list, as shown below. Click OK again to save all the changes
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
- Navigate to the site where you manage your content types (this could be any site or site collection root again)
- Gear Icon > Site Settings
- Click on Site Content Types (under Web Designer Galleries)
- Navigate to or create a new content type (I explain how to do this in this post)
- Click on Information management policy settings
- 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 button
- 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.
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.
- Navigate to the library where content is stored (any subsite within the site collection)
- Click on Information management policy settings
- 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.
- 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 source
- 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 OK
- You will get a warning message, just click OK
- Once changed, your source should say: Library and Folders, just like in image below
- To configure retention or deletion policy for a document library and folders, click on Change source or configure library schedule
- 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 policy
- 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.
- 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.
- Click on any of the folders on the left-hand side, and then define/add a retention stage as necessary. Click Apply and OK
- 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 folder
- 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:
- Go to the root of the site collection, then Gear Icon > Site Settings
- Site Collection Features (under Site Collection Administration)
- Navigate to Library and Folder based Retention, then click Deactivate
- You will then get a warning message, click on Deactivate this feature
- Once deactivated, users will no longer be able to change the source as we did in previous steps, as demonstrated by image below.
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:
- Go to Library Settings, then click on Generate file plan report
- On next screen, specify where you want to save it (default location is the same document library). Click OK
- You can then click to view the report or navigate to the library where you will find it as well
- The Excel output file contains several tabs with various details, but most importantly shows you the different policies set for the library and/or folders
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).