This post is answering a blog post question from my Retention in SharePoint Online: The WHEN post. Since #sharingiscaring, I thought I’d answer it in the form of another post instead of just replying to one person in the comments.
Reader question: I have a question about “Retain for / Delete after ‘x’ based on labeled date”. I have a document where the close date (a custom date column for the document) is the date which will determine the start of the retention. In this case, what would be the best way to trigger the retention? Do I have to use event or there is a better way available?
There are 4 ways of accomplishing this, depending on the license available to you, the number of documents associated to the custom date, how automated you want/need it to be, and, beyond that, your preference.
Option 1: Use Event-based retention triggered on a Custom event Date
I wouldn’t use event-based retention for the single-document scenario described in the question. Event-based retention is a good option if you have a lot of documents all relating to the same event date and with the retention label already set.
Good examples where I’ve seen this option used are:
- all documents for a project start retention on the project completion date
- all documents for a legal matter start retention on the matter resolved date
For event-based retention, in addition to the retention label, you’d also need to assign a unique identifier to all documents relating to the event (referring back to the previous examples that unique identifier would be project # or legal matter #).
An event is created on the event date and then retention will start on all documents with the retention label and the same unique identifier.
Refer to a post by Martin Lingstuyl here: Blimped | Working with Purview event-based retention using code where he explains how to work with an event-based retention label and the ComplianceAssetId all thru code!
Option 2: Use Auto-apply on a Retention Label based on a Custom Date
This would be a good way of applying the retention based on a custom date. Set up your retention label to start retention based on labeled date. To filter on a date column, you must map it’s crawled property to a RefinableDate column (it’s queryable). In this example, I mapped it to RefinableDate01 and this would be the auto-apply condition below:
The result? Within a week, any SharePoint site the retention label is published to will have the retention label applied to all documents when a date either equal to today or in the past has been entered into the custom date column.
Note: if a date isn’t entered in the column OR a future date is entered in the column, a retention label is not applied.
I’ve blogged about this here: Retention in SharePoint Online: the HOW in “#7 – Auto-apply based on a metadata value”.
Option 3: Use a Power Automate Flow
This would be a very flexible way of applying your retention label if you need retention to start when a label is applied.
Build a Power Automate Flow to periodically (daily, weekly?) retrieve the items in your library with an ODATA filter to only bring back those items when the custom date is <= today
You can then programmatically apply the retention label using the ‘Send an HTTP Request to SharePoint’ action. I’ve blogged about this here: Retention in SharePoint Online: the HOW in “#9 – Automatically set using Power Automate”.
Option 4: Remind someone to do it! 🙂
Get the administrator of your library to set up a “Remind me” workflow for them to be reminded when a custom date on the library has been reached.
When the reminder is received, the retention label (configured to start retention when its applied) can be manually applied! This would only be a feasible option if the volume of documents was not large.
Hope this answer helped and gave you some ideas!