Thursday, January 24, 2013

Check if Item is in document set in SharePoint 2010

In this post we will discuss how to check if an item is present in a document set programmatically using SharePoint 2010 object model.

You can also check my previous posts on: WebPart custom Properties, Download CAML designer for SharePoint 2013 and What you can do with Sandboxed Solutions?

To work with document sets using SharePoint 2010 object model, we have to use

Microsoft.Office.DocumentManagement.DocumentSets namespace.

Below is the full code:

public bool IsDocumentSetItem(SPListItem itemToCheck)
bool documentSetItem = false;

if (itemToCheck.File != null)

DocumentSet documentSet = DocumentSet.GetDocumentSet(itemToCheck.File.ParentFolder);

if (null != documentSet)
documentSetItem = true;
return documentSetItem;

No comments:

Post a Comment