Programmatically Get Document Set for a document SharePoint 2010
The Code below checks Whether the document item "itemToCheck" belongs to any document set and if yes it returns the document set name.
public bool IsDocumentSetItem(SPListItem itemToCheck)
{
bool documentSetItem = false;
if (itemToCheck.File != null)
{
DocumentSet documentSet;
documentSet = DocumentSet.GetDocumentSet(itemToCheck.File.ParentFolder);
if (null != documentSet)
{
documentSetItem = true;
}
}
return documentSetItem;
}
The code asks the current item to return the containing set. If there is no set, then the item is not part of any document set.
public bool IsDocumentSetItem(SPListItem itemToCheck)
{
bool documentSetItem = false;
if (itemToCheck.File != null)
{
DocumentSet documentSet;
documentSet = DocumentSet.GetDocumentSet(itemToCheck.File.ParentFolder);
if (null != documentSet)
{
documentSetItem = true;
}
}
return documentSetItem;
}
The code asks the current item to return the containing set. If there is no set, then the item is not part of any document set.
0 comments:
Post a Comment