Hey,
The requirements was to create a new List Instance using CAML approach with some Metadata Navigation Settings pre-configured into it as in my list I have used a Managed Metadata Field.
This turned out to be harder than I thought !!!
After Googling I came to the post by Corey Roth which help understand the concept of MetadataNavigationSettings used as a CAML.
Now, where to find the Value of client_MOSS_MetadataNavigationSettings Property, I tried to rebuild the CAML manually using the common sense and doing some trial and error with the MetadataField FieldID GUID however it wasn't working...
Thereafter, I decided to get the value programmatically - for that I created a dummy Document Library and I got the XML Value of the client_MOSS_MetadataNavigationSettings using the below code and VOILA - I got the value.
Enjoy!
The requirements was to create a new List Instance using CAML approach with some Metadata Navigation Settings pre-configured into it as in my list I have used a Managed Metadata Field.
This turned out to be harder than I thought !!!
After Googling I came to the post by Corey Roth which help understand the concept of MetadataNavigationSettings used as a CAML.
Now, where to find the Value of client_MOSS_MetadataNavigationSettings Property, I tried to rebuild the CAML manually using the common sense and doing some trial and error with the MetadataField FieldID GUID however it wasn't working...
Thereafter, I decided to get the value programmatically - for that I created a dummy Document Library and I got the XML Value of the client_MOSS_MetadataNavigationSettings using the below code and VOILA - I got the value.
SPDocumentLibrary lib = (SPDocumentLibrary)site.OpenWeb().Lists["SharedDocuments"];var res = lib.RootFolder.Properties["client_MOSS_MetadataNavigationSettings"];Once I got the value, I converted the XML tag into HTML - These 3 symbols only:
" by "Finally, my Elements.xml looks like:
< by <
> by >
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance FeatureId="{00bfea71-e717-4e80-aa17-d0c71b360101}" TemplateType="101" Title="MyDocuments" Description="" Url="MyDocuments" CustomSchema="Files\MyDocuments\Schema.xml" HyperlinkBaseUrl="http://zin506/sites/TeamSite" RootWebOnly="FALSE" xmlns="http://schemas.microsoft.com/sharepoint/" OnQuickLaunch="TRUE" />
<PropertyBag Url="MyDocuments" ParentType="Folder" RootWebOnly="FALSE" xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Name="client_MOSS_MetadataNavigationSettings" Type="string"
Value="<MetadataNavigationSettings SchemaVersion="1" IsEnabled="True" AutoIndex="True">
<NavigationHierarchies>
<FolderHierarchy HideFoldersNode="True" />
<MetadataField FieldID="7ced7787-dcf6-4748-a23e-f0248f89db58"
FieldType="TaxonomyFieldType"
CachedName="Category"
CachedDisplayName="Category" />
</NavigationHierarchies>
<KeyFilters />
</MetadataNavigationSettings>" />
</PropertyBag>
</Elements>
Enjoy!
No comments:
Post a Comment