Just little about C#, .NET, SQL Server, SharePoint and SAP

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.



5 Responses to “Custom Document Expiration Policy – Part-1: Overview”

  1. […] Custom Document Expiration Policy – Part-1: Overview […]

  2. zieglers said

    Q: What is this cat doing?

    A: Checking expiration dates 🙂

    Then, our conclusion is…

    Cat is SharePoint Expiration Timer Job!
    Fridge is SharePoint site collection!!
    Shelves are expiration policy enabled libraries!!!
    Time of the day: hmm, probably between 11pm and 11:30pm!!!!

  3. […] Custom Document Expiration Policy – Part-1: Overview […]

  4. webbdog said

    You wouldn’t mind posting the source code, would you? I’ve got a project that needs to do almost exactly what you’ve accomplished.

  5. […] provides a cool intro, implementation sample and much […]

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: