Custom Document Expiration Policy – Part-3: Additions
Posted by zieglers on January 18, 2010
This post will detail some functional extensions implemented for Custom Expiration Policy.
You can find previous posts related to Custom Expiration Policy here:
- Custom Document Expiration Policy (https://zieglers.wordpress.com/2010/01/18/custom-document-expiration-policy-part-1-overview/)
- Custom Document Expiration Policy – Implementation Details (https://zieglers.wordpress.com/2010/01/18/custom-document-expiration-policy-part-2-implementation/)
Previously, we implemented our custom expiration policy to take advantage of OOTB delete action. This means when a document expires, it is simply deleted.
In this post we’ll look into details of how to perform a custom action when document expires. Here are the requirements for custom action:
- First, log expiration warning details to a list called Expiration Warnings.
- Then, upon expiration, log expiration details to a list called Expiration History.
- Finally, delete document.
So, that’s how Expiration Warnings and Expiration History lists look like.
Once our custom expiration action is deployed, it shows up in expiration settings under ‘Perform this action‘ dropdown list. I called it ‘Expiration Event Logger‘.
Implementation of custom expiration action is similar to implementation of expiration formula calculation. All we need to do is to implement IExpirationAction interface which can be found in Microsoft.Office.RecordsManagement.PolicyFeatures namespace.
Above OnExpiration method is called once document expires. Here, first we are creating Expiration History List and then deleting the expired document.
In order to create a list and write an entry in it, i used a helper class called ExpirationHistoryList, whose implementation can be seen below.
There is only one constructor. This constructor gets Expiration History List object if created. If it’s not created yet, it creates one.
In addition, WriteEntry method creates log entry in the list along with expiration event details such as document title, list name, web title, … etc.
That concludes this post – logging functionality for expiration policy.
Things to do next: Managing document expiration once expiration warning period is reached using Expiration Warnings list.