When I first used Sharepoints Information management policy settings I thought it would be easy to set an Expiration Policy on my list items. This seemed like a perfect fit for the requirement I was working on.
Was it Straight Forward? Yes and No.
But once I sorted out my issues I managed to quickly get it working. Firstly the reason I wanted to do this was because my client had a requirement to delete items in a list once they'd been there a couple of weeks. Easy I thought....
So I went ito the Settings Page of the List
Then I clicked on the Information management policy settings link.
I then selected Define a Policy.
On the following screen I checked the Enable Expiration box.
This gave me futher choices..... But the choice I wanted to select was greyed out! I wanted to select A time period based on the item's properties: ... but it wouldn't let me because I didn't have a date field to select from! This is when I started shouting "What about the Created Date" followed by "What about the Modified Date".
Once I'd calmed down I tried several ways to try and trick this policy by adding hidden fields to my list. It still didn't give me the desired result I was after.
So I needed a new plan....
So my attention turned to Site Collection Policies (Site > Site Settings > Site Collection Policies). This seemed like the way forward. Set a policy at the Site level and then select it from the List settings Information management policy settings page. But surely it will give me the same problem.... won't it?
When I clicked on the Site Collection Policies I got an Access Denied Error! So I started screaming - "I am a *#$%$#@ Site Collection administrator how can I not have access".
Well once I looked into it further I realised that I need some sort of permission to be able to access this page. So I decided to make sure I had all the available permissions assigned to my Web Application. I did this with the code below -
SPWebApplication WebApp = SPWebApplication.Lookup("http://MySitesUrl");
WebApp.RightsMask = WebApp.RightsMask | SPBasePermissions.FullMask;
WebApp.Update() ;
This can just as easily be done through the UI. See Gary Lapoints blog at - http://stsadm.blogspot.com/2007/10/enumerate-effective-base-permissions.html
Once I had done this I had access to the Site Collection Policies page.... Once there I added my expiration policy and then went and added it to my list through the Information management policy settings page.
After waiting for the Policy to run (This happens daily) I went back to double check my expire items had been deleted.... And they had. Success!
Hope this helped.
Tuesday, February 17, 2009
Subscribe to:
Posts (Atom)