none
SP2010 Calendar List View Threshold Remove Old Items RRS feed

  • Question

  • Hello,

    We currently have a calendar used to schedule and reserve items in SharePoint 2010. It is rapidly approaching it's list view threshold. I know how to extend the threshold but I was wondering if there is an easy way to remove old items to clear the list instead? For example I would like to remove all the entries from January 2013 and below.

    Thanks in advance!

    Wednesday, September 18, 2013 1:22 PM

Answers

  • Hello,

    It sounds like you need an information management policy.  You can set that up by going into the list settings page (or in your case click the Calendar tab in the Ribbon and click the List Settings button).  Once there peform the following:

    1. Click the Information management policy settings link

    2. Click the "Event" content type link under Content Type Policies

    3. Check the Enable Retention checkbox (and enter an Administrative Description and Policy Statement if you want to)

    4. A hidden section will appear.  Click the Add a retention stage... link.

    5. Specify what causes the stage to activate (for example choose the Time Period to be Start Time is older than 6 months: Choose Start Time field and then enter 6 in the textbox and choose months from the dropdown).

    7. Define your Action (choose from the available options).  For example move it to the Recycling bin or Permanently Delete.

    8. Click OK to close the popup.  Check the Enable Auditing check box if you want Auditing turned on, otherwise just click OK to save the policy.

    This allows some timer jobs (already running as part of SharePoint) to check for and automatically delete or archive the items in your list (in your case old events).  If you need more detailed options, check out these links:

    http://msdn.microsoft.com/en-us/library/ms499244.aspx

    http://blogs.msdn.com/b/mvpawardprogram/archive/2011/10/03/applying-document-retention-in-sharepoint-2010.aspx

    Hope this helps,

    ~ Katie

    Wednesday, September 18, 2013 2:27 PM

All replies

  • Hello,

    It sounds like you need an information management policy.  You can set that up by going into the list settings page (or in your case click the Calendar tab in the Ribbon and click the List Settings button).  Once there peform the following:

    1. Click the Information management policy settings link

    2. Click the "Event" content type link under Content Type Policies

    3. Check the Enable Retention checkbox (and enter an Administrative Description and Policy Statement if you want to)

    4. A hidden section will appear.  Click the Add a retention stage... link.

    5. Specify what causes the stage to activate (for example choose the Time Period to be Start Time is older than 6 months: Choose Start Time field and then enter 6 in the textbox and choose months from the dropdown).

    7. Define your Action (choose from the available options).  For example move it to the Recycling bin or Permanently Delete.

    8. Click OK to close the popup.  Check the Enable Auditing check box if you want Auditing turned on, otherwise just click OK to save the policy.

    This allows some timer jobs (already running as part of SharePoint) to check for and automatically delete or archive the items in your list (in your case old events).  If you need more detailed options, check out these links:

    http://msdn.microsoft.com/en-us/library/ms499244.aspx

    http://blogs.msdn.com/b/mvpawardprogram/archive/2011/10/03/applying-document-retention-in-sharepoint-2010.aspx

    Hope this helps,

    ~ Katie

    Wednesday, September 18, 2013 2:27 PM
  • Hi Artist Of Apathy, 

    Katies answer is a good ongoing solution to manage old items. 

    If you just want to quickly delete old items, you can do so with a PowerShell script, using the Batch delete method. I wrote about this on my blog, here, http://matthewyarlett.blogspot.co.uk/2013/07/well-that-was-fun-bulk-deleting-items.html and on the TechNet Wiki, http://social.technet.microsoft.com/wiki/contents/articles/19036.sharepoint-using-powershell-to-perform-a-bulk-delete-operation.aspx here E.g.

    $list =  (Get-Spweb "http://yoursite").GetList("http://yoursite/Lists/youreventlist")
    $query = New-Object Microsoft.SharePoint.SPQuery;
    $query.ViewAttributes = "Scope='Recursive'";
    $query.RowLimit = 2000;
    $query.Query = '<Where><Lt><FieldRef Name="EndDate"/><Value Type="DateTime" IncludeTimeValue="TRUE">2013-01-01T00:00:00Z</Value></Lt></Where>';
    
    $itemCount = 0;
    $listId = $list.ID;
    [System.Text.StringBuilder]$batchXml = New-Object "System.Text.StringBuilder";
    $batchXml.Append("<?xml version=`"1.0`" encoding=`"UTF-8`"?><Batch>");
    $command = [System.String]::Format( "<Method><SetList>{0}</SetList><SetVar Name=`"ID`">{1}</SetVar><SetVar Name=`"Cmd`">Delete</SetVar></Method>", $listId, "{0}" );
    
    do
    {
        $listItems = $list.GetItems($query)
        $query.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
        foreach ($item in $listItems)
        {
            if($item -ne $null){$batchXml.Append([System.String]::Format($command, $item.ID.ToString())) | Out-Null;$itemCount++;}
        }
    }
    while ($query.ListItemCollectionPosition -ne $null)
    
    $batchXml.Append("</Batch>");
    $itemCount;
    
    $web = Get-Spweb "http://yoursite";
    $web.ProcessBatchData($batchXml.ToString()) | Out-Null;

    The other alternative, is to create indexes on the list (you need to index all the columns used in order by and where clauses in the various views). That way, you don't need to extend (or worry about) the list view threshold. I have a number of applications that have hundreds of thousands of list items, and the list views work fine, because the indexing is setup correctly. 

    There is a good article on query throttling and indexing here: http://msdn.microsoft.com/en-us/library/ff798465.aspx


    Regards, Matthew
    MCPD | MCITP
    My Blog
    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

    I just added a webpart to the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here: Upload and Crop User Profile Photos

    Wednesday, September 18, 2013 2:52 PM
  • Thank you Katie!

    I set this up. Unfortunately it doesn't seem to be doing anything. Does it take a while to start deleting the old items?

    Thanks again!

    Wednesday, September 18, 2013 2:59 PM
  • Yes, usually they run every day (or every hour), depending on how it's configured in Central Administration.  Check out this link for some more detailed information on that: http://sportstoday.us/technology/sharepoint-2010---farm-governance---learning-timer-job-management-(including-server-affinity).aspx.

    ~ Katie

    Wednesday, September 18, 2013 3:09 PM
  • Hello,

    Dear Katie,

    I am resurrecting an old thread, hoping you or someone else will answer it. I am having the exact problem as described above. We use multiple SharePoint calendars to manage our graduate school department. We have always managed these calendars via connecting them in outlook. The calendar items are added, modified, deleted, etc. inside outlook. Recently, our University changed to web based office from self contained servers. For some reason, that change has caused us to not be able to sync the calendars with outlook due the the 5000 tab limit. I applied the policy defined above and nothing happened. What I am trying to do is to delete (automatically, and repetitively if possible) by applying a policy as described above. Any ideas why nothing happened?  I am seeing no change in the > 7000 tabs after applying this change. 
    Thanks much,
    Patrick Loftis

    patrick(dot)loftis@marquette(dot)edu  

    Monday, February 13, 2017 3:46 PM