Wednesday, February 20, 2013

SharePoint 2010 : Content types that are available to this Document Set have been added or removed. Update the Document Set.

Sometimes when we click on a document set and within the same we see a yellow line reading 
Content types that are available to this Document Set have been added or removed. Update the Document Set.
The reason behind it is that this document set is not created using the OOB way but using some kind of code practices. Ideal way to create document set is by using 

- DocumentSet.CreateDocumentSet

which sets the docset_LastRefresh property. But doing it in any other way doesn't set this property resulting in the above warning message. To get over with this, we should manually write the code to set the property and prevent seeing this warning in every document set created this way.

SPFolder docSet = web.GetFolder("site/doc lib/folder");
docSet.Item.Properties["docset_LastRefresh"] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.UtcNow);
docSet.Item.SystemUpdate(false);


No comments: