Programmatically get all the items from Hold Reports list in Sharepoint


In this article we will be seeing how to get all the items from the Hold Reports list using SharePoint object model.

I have a SharePoint site and I have activated the Site feature (Go to Site Actions => Site Settings => Site Actions => manage Site features) "Hold and eDiscovery". Once you have the feature activated you could be able to see the new custom group as shown in the following

Go to Site Actions => Site Settings => Hold and eDiscovery

ReportList1.gif

I have two items in the "Hold Reports" as shown in the following.

ReportList2.gif

We are going to retrieve these items using object model.

We will be using Hold.GetHoldReportsList Method to get a list of items currently on hold for the specified SharePoint site.

Hold.GetHoldReportsList Method

Gets a list of items currently on hold for the specified SharePoint site.

  • Namespace: Microsoft.Office.RecordsManagement.Holds
  • Assembly: Microsoft.Office.Policy (in Microsoft.Office.Policy.dll)

Steps Involved:

  • Open Visual Studio 2010.
     
  • Create a new console application.
     
  • Add the following references.

    1. Microsoft.Office.Policy.dll
    2. Microsoft.SharePoint.dll
     
  • Add the following namespaces.

    1. Using Microsoft.Sharepont;
    2. Using Microsoft.Office.RecordsManagement.Holds;
     
  • Replace the code with the following.

    ReportList3.gif
     
  • Build the solution.
     
  • Hit F5.
     
  • Output:

    ReportList4.gif

erver'>