Custom Document Expiration Policy – Part-1: Overview
Posted by zieglers on January 18, 2010
In this post, i’ll try to mention what ‘Custom Expiration Policy‘ is and how you can develop one for your needs.
SharePoint comes with ECM (Enterprise Content Management) capabilities and probably most important building block of ECM is ‘Policies‘. They are also called IMPs (Information Management Policy) withing SharePoint domain. OOTB ones are Labels, Auditing, Expiration and Barcodes. In this post i’ll focus on Expiration Policy, why we need to customize it and how it can be customized.
SharePoint definition of Expiration Policy: “Automatic scheduling of content for processing, and expiry of content that has reached its due date.”
Simply saying ‘Set an expiration date on documents. Once due date is reached, perform an action.’ Here, the main parts are Expiration Date and Action Performed once document expires.
MOTIVATION: Customization need comes into play right at this point. OOTB SharePoint functionality only allows you to set expiration date based on two fields: Created Date and Modified Date. In real life scenarios, setting an expiry date only based on those two fileds may not be sufficient. Also, you might want to do some custom checks or look-ups while setting this date. Another important requirement leading to customization can be the necessity of sending warning emails before document expires.
Hence, I developed a POC to demonstrate how Custom Expiration Policy works.
POC Requirements: POC scenario is really simple.
- Set Expiration Date to Last Modified Date + 5 mins.
- Send warning email within last 2 mins. (This is customization part).
- Delete document when it expires.
POC in ACTION: Now, let’s see how it works.
To test custom expiration policy, i created a test document library called ‘Test’ and defined a policy for this library in ‘Document Library Settings > Information Management Policy Settings’.
Define a policy…
Here enable expiration policy and select custom expiration formula as shown below.
You’ll notice that there is an additional entry for retention period choice, which is “Set by a custom retention formula installed on this server“. Our custom formula name is “SomeCompanyName Custom Expiration“. This entry shows up once you deploy your custom policy resource. We’ll get back into details later about that.
Now, let’s upload a test document to library.
As you can see above, Expiration Date is set to Modified + 5 minutes by our custom expiration formula.
So far so good. Our expectation is now to get a warning email after 3 mins. Normally, SharePoint Expiration Timer Job runs daily between 23:00 and 23:30. But if you don’t want to wait for this you can force it to run in Central Admin.
For demonstration purposes, that’s what i did. Now i check my inbox and here is my warning email. (Message body says “will expire in a month“. Ignore that, since this will be eventually in finalized version of this POC)
Now, I expect to see that document is deleted after 2 mins, which in total makes 5 mins, retention period.
… wait wait wait … one minute passed … wait wait wait … two minutes passed … check test library …
Document is deleted!!! Mission accomplished
So this completes our ‘Custom Expiration Policy‘ scenario.
I think so far is enough for this post. I’ll try to show implementation details in another post.