Custom Document Expiration Policy – Part-4: Managing Expiration
Posted by zieglers on January 28, 2010
In this post, i’ll try to show how expiration warnings can be managed. Basically managing warnings includes some custom menu actions such as:
- Collect Documents - When this action is selected, selected documents are flagged so that they are forced to expire immediately. (Here immediately actually means ‘next time Expiration Timer Job runs’). In other words, selected documents are deleted next day. (Usually expiration timer job runs at 11pm)
- Reset Expiration Dates – When this action is selected, Last Modified Date of documents are set to Now, so that expiration formula runs again and ExpirationDate field of document is updated based on the formula defined. (ExpirationPeriod and ExpirationWarning values can be set in Web.Config. I’ll also show that in this post)
As I mentioned in previous post (http://zieglers.wordpress.com/2010/01/18/custom-document-expiration-policy-part-3-additions/) of ‘Custom Document Expiration Policy‘ posts series, once documents are in expiration warning period, a list entry is created in Expiration Warnings List. From this list, using Actions menu items you can manage document expiration as mentioned above.
Demo: In our demo, i upload a document to a library for which expiration policy has already been applied.
I set ExpirationPeriod value to 5 mins and ExpirationWarning value to 3 mins in web.config for that web.
This means after 2 minutes, document i upload will be in Expiration Warning Period and a warning entry will be created in Expiration Warnings list.
Now, I enable ‘Multiple Item Selection’ feature for this library. This feature is necessary if we want to process more than one item in bulk. Item selection can be enabled/diabled using custom actions menu item as shown below.
Once you enable item selection, you’ll see a checkbox next to each list entry, so that you can select multiple items to process. (Cool,eh?!? This is actually achieved by using JQuery. I’ll also try to show details of it in another post. Stay tuned…)
Reset Expiration Dates:
Let’s select above item and, for instance, let’s reset expiration date for that document. In order to do so, after selecting the item, i click ‘Reset Expiration Dates’ custom actions menu item.
Then, i get a nice pop-up message to confirm this operation.
… and i click OK, so that expiration date of this document gets resetted.
Please take a careful look at above screenshot and first screenshot of this post.
You’ll see that in first screenshot, Last Modified time is 3:39pm and Expiration time is 3:44pm. Then, i resetted expiration date for this document at 3:44pm, as a result of this Expiration time in above screenshot is 3:49pm, which is 5 minutes later than last modification time.
This shows us that once i clicked ‘Reset Expiration Dates’, expiration date was calculated again based on our custom defined expiration formula.
Collect Documents action is to force documents to expire immediately. This is achieved by setting a boolean field CollectMe to Yes. Also Expiration Date field is set to Now.
Since in my demo environment, i have set up Expiration Timer Job to run every minute, when i check document library after one minute, I see that my test document is deleted/collected.
Here is a demo of how it works:
Similar to Reset Expiration Dates scenario, first I upload my test document.
Then, after 2 minutes, when document is in Expiration Warning Period, warning entry is created in Expiration Warnings List.
Once again enable item selection and select test document.
Then, go to Actions Menu and select “Collect Documents-To-Expire“.
At this point CollectMe field is set to YES and Expiration Date field is set to Now. When we go to document library we can see updated fields as shown below.
Also note that Modified and Expiration Date field values are same, which tells us that Expiration Date is set to Now.
Finally, checking the document library after 1 minute, I see that expiration occurred and my test document is deleted/collected. (Moreover, another log entry is created in Expiration History list for this expiration event.)
So, this concludes Managing Expiration post.
Please let me know if you have any suggestions/comments re usability/functionality of Expiration Management feature.