Question

I'm having a workflow that creates alot of documents in a single library. I know I'm going to exceed the limit of 5000 pretty fast. Old documents can be deleted so the question is: Is there a simple way to delete old files automatically?

The best way would be if there where a option that sharepoint deletes the oldest items in the list if it exceed the list view threshold.

The only way I can think of is to run a timer job / scheduled task that runs every night and delete the oldest files if it exceed like 4000.

Was it helpful?

Solution

Deleting files is not an answer when a SharePoint library can contain millions of files without any performance issues. List View threshold is not about the number of items in a list. It is more about the views. The number of items returned by a particular view should not exceed it as it causes performance issues. You should instead look to filter your views so that they return data below threshold limit.

OTHER TIPS

If you're using SharePoint 2010 or newer you could possibly look into Information Management Policy.

Policy and Retention in SharePoint Server 2010 - should still apply for SP2013 on-premise.

It is however date based. Otherwise a timerjob is a pretty solid alternative as you control the circumstances of when to do what.

You may consider creating a "Retention" Policy for your document Library :

Go to the doc lib settings, and choose "Information management policy settings". Then select "Enable Retention" and configure it by adding stages (you can send the file to the bin in one stage, after a given period from file creation).

If "Information management policy settings" is missing, try to activate the site collection feature "Library and Folder Based Retention".

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top