Logo 
Search:

Sharepoint 2010 Articles

Submit Article
Home » Articles » Sharepoint 2010 » Content ManagementRSS Feeds

Check whether the item is in hold in SharePoint 2010

Posted By: Vijai Anand Ramalingam     Category: Sharepoint 2010     Views: 1883

In this article we will be seeing whether the list item is in hold in SharePoint 2010 using object model.

 

In Shared Documents I have a document "New”, here I am going to check whether the item is in hold or not using SharePoint object model.

  • Open Visual Studio 2010.
  • Create a new console application.
  • Add the following references. 
    • Microssoft.Office.Policy.dll
    • Microsoft.SharePoint.dll
  • Add the following namespaces. 
    • using Microsoft.SharePoint;
    • using Microsoft.Office.RecordsManagement.Holds;
  • Replace the code with the following.

using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Microsoft.SharePoint;
using
System.Xml;
using
Microsoft.SharePoint.Administration;
using
Microsoft.Office.RecordsManagement.Holds;
namespace
Holds
{
    classProgram
    {
        staticvoid Main(string[] args)
        {
            using (SPSite site = newSPSite("http://servername:22222/sites/Test/"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    SPList list = web.Lists["Shared Documents"];
                    foreach (SPListItem item in list.Items)
                    {
                        if (item.DisplayName.ToString() == "New")
                        {
                            if (Hold.IsItemOnHold(item))
                            {
                                Console.WriteLine(item.DisplayName + " is on hold");
                                Console.ReadLine();
                            }
                        }
                    }
                }
            }
        }
    }
}
Share: 


Didn't find what you were looking for? Find more on Check whether the item is in hold in SharePoint 2010 Or get search suggestion and latest updates.

Vijai Anand Ramalingam
Vijai Anand Ramalingam author of Check whether the item is in hold in SharePoint 2010 is from India. Vijai Anand Ramalingam says Hello Everyone,
I am Vijai Anand Ramalingam from India
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!