Sunday, April 24, 2016

How to retrieve Location based metadata defaults using CSOM ?


Location based metadata defaults is a great feature to manage default values for documents in SharePoint Document Library. It allows to configure default values for document library, folders, sub folders etc. based on location / hierarchy so users will not have to provide the metadata values when they upload the documents in the document library.

To retrieve metadata defaults values programmatically, you will have to use Full trust object model because metadata defaults objects however are only available in Full trust object model. There is no REST API or Client Side Object Model (CSOM) API has been exposed to retrieve metadata defaults from SharePoint.

But we found the way of how SharePoint manages metadata defaults functionality, so we can retrieve metadata default in some clever way.

SharePoint stores metadata defaults in some html file (client_LocationBasedDefaults.html) in Document library itself. This file (client_LocationBasedDefaults.html) is stored in Forms folder of Document Library. You can find it out in SharePoint designer.





This file saves data in XML format with location / hierarchy (URL mapped with library, folder, sub folder etc.), Fields internal names and their default values as per configuration.




So you can just download this file using your C# code and read the content of this. So this way now you have all metadata defaults values available in your CSOM application. Enjoy!!

Thursday, April 21, 2016

Location based Metadata defaults in SharePoint Document Library

Introduction:

Location based metadata defaults is a great feature to manage default values for documents in SharePoint Document Library. It allows to configure default values for document library, folders, sub folders etc. based on location / hierarchy so users will not have to provide the metadata values when they upload the documents in the document library.

How to setup Metadata defaults in Document Library ?

Following steps give you a very quick overview on how to configure the default column values feature in SharePoint. (These screenshots are for SharePoint 2013, but it’s almost identical in 2010 as well).


Open Document Library --> Library Settings --> General Settings --> Column default value settings


Here you can configure default values for several fields (Fields those support metadata defaults) for different location/ hierarchies.



If you don't configure default values for any folder or sub folder then it will be inheriting default values from its parent hierarchy otherwise its own configured default values.

Once you configured default values, go to your Document library or folder inside it and try adding any document, you will be having configured default values auto filled in those fields in Edit metadata form. Enjoy!!