<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.dotnetmafia.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Corey Roth [MVP] : CAML</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx</link><description>Tags: CAML</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>How to: Query List Items from the Host Web in a Client Web Part of a SharePoint Hosted app</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/10/26/how-to-query-list-items-from-the-host-web-in-a-client-web-part-of-a-sharepoint-hosted-app.aspx</link><pubDate>Fri, 26 Oct 2012 13:30:30 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:5976</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=5976</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/10/26/how-to-query-list-items-from-the-host-web-in-a-client-web-part-of-a-sharepoint-hosted-app.aspx#comments</comments><description>&lt;p&gt;That’s a mouthful, but I wanted to make sure that people knew exactly what this post is for.&amp;#160; The problem I am seeing out there already is that while there is a lot of code samples, they aren’t clear for what type of app the sample is for.&amp;#160; If you are doing a provider hosted app for example, the way you query list items is different (using the Cross-Domain Library).&amp;#160; Today’s topic boggled me though because while I found plenty of &lt;a href="http://msdn.microsoft.com/en-us/library/jj163201(v=office.15).aspx"&gt;samples&lt;/a&gt; on how to query list items using CSOM from an app, they were all in-fact incorrect for a SharePoint hosted app.&amp;#160; The article I linked is great by the way.&amp;#160; It has many of the things you need to know how to do via CSOM in an app so be sure and check it out.&lt;/p&gt;  &lt;p&gt;Now to get on to the scenario I want to help you with today.&amp;#160; If you are building a Client Web Part, you may have stumbled upon my previous articles on the topic (&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/10/19/how-to-use-the-sharepoint-2013-client-object-model-sp-js-from-a-client-web-part.aspx"&gt;JavaScript&lt;/a&gt; and &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/08/01/how-to-build-a-sharepoint-hosted-client-web-part-in-sharepoint-2013.aspx"&gt;Getting Started&lt;/a&gt;).&amp;#160; These are great articles to get you started, however, it turns out I left out the details on how to query list items from a SharePoint hosted app.&amp;#160; Like many things, it’s not as simple as I thought it was.&amp;#160; I thought it was just a matter of passing another URL into get_web().&amp;#160; I was wrong.&amp;#160; I then saw some examples and thought I just need to pass the URL into a new SPContext object.&amp;#160; Also wrong.&amp;#160; While, you can do that, once you make the call to get your list items, you’ll quickly find yourself with an Access Denied error coming from MicrosoftAjax.js.&amp;#160; I gave up and posted something to the &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/appsforsharepoint/thread/95643072-ff06-42b8-9e6e-8ab65973c557/"&gt;forums&lt;/a&gt; and luckily &lt;a href="http://social.msdn.microsoft.com/profile/elisabeth%20olson/?ws=usercard-mini"&gt;Elisabeth Olson&lt;/a&gt; from MSFT came through with the answer.&amp;#160; In my solution, I start with some global variable declarations.&lt;/p&gt;  &lt;div style="font-size:10pt;font-family:consolas;background:white;color:black;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; context;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; web;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; user;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; spHostUrl;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; parentContext&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Then the code looks similar to that from my article on &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/10/19/how-to-use-the-sharepoint-2013-client-object-model-sp-js-from-a-client-web-part.aspx"&gt;SP.js&lt;/a&gt;.&amp;#160; In the document ready function, I get the spHostUrl with the following line of code.&amp;#160; You can get that &lt;em&gt;getQueryStringParameter&lt;/em&gt; method from my previous article as well.&amp;#160; Remember, the SPHostUrl comes from the {StandardTokens} parameter in your Client Web Part’s elements.xml file.&lt;/p&gt;  &lt;div style="font-size:10pt;font-family:consolas;background:white;color:black;"&gt;   &lt;p style="margin:0px;"&gt;spHostUrl = decodeURIComponent(getQueryStringParameter(&lt;span style="color:#a31515;"&gt;&amp;#39;SPHostUrl&amp;#39;&lt;/span&gt;));&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Now, we set up our context and here is where things are a bit different.&amp;#160; First, we get our context object using &lt;em&gt;SP.ClientContext.get_current()&lt;/em&gt; as usual.&amp;#160; However, we have to get a new context by using SP.AppContextSite and passing in the current context along with the Host Url.&lt;/p&gt;  &lt;div style="font-size:10pt;font-family:consolas;background:white;color:black;"&gt;   &lt;p style="margin:0px;"&gt;context = &lt;span style="color:blue;"&gt;new&lt;/span&gt; SP.ClientContext.get_current();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;parentContext = &lt;span style="color:blue;"&gt;new&lt;/span&gt; SP.AppContextSite(context, spHostUrl);&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;After that, we just need to get our SPWeb object using the &lt;em&gt;parentContext&lt;/em&gt;.&lt;/p&gt;  &lt;div style="font-size:10pt;font-family:consolas;background:white;color:black;"&gt;   &lt;p style="margin:0px;"&gt;web = parentContext.get_web();&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;At this point, it’s business as usual to do our queries.&amp;#160; Get the list, set a CAML query, load the getItems call, and then execute the query.&lt;/p&gt;  &lt;div style="font-size:10pt;font-family:consolas;background:white;color:black;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; list = web.get_lists().getByTitle(&lt;span style="color:#a31515;"&gt;&amp;quot;My List&amp;quot;&lt;/span&gt;));&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; camlQuery = &lt;span style="color:blue;"&gt;new&lt;/span&gt; SP.CamlQuery();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;camlQuery.set_viewXml(&lt;span style="color:#a31515;"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;this&lt;/span&gt;.listItems = list.getItems(camlQuery);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;context.load(listItems);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;context.executeQueryAsync(Function.createDelegate(&lt;span style="color:blue;"&gt;this&lt;/span&gt;, &lt;span style="color:blue;"&gt;this&lt;/span&gt;.onQuerySucceeded),&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; Function.createDelegate(&lt;span style="color:blue;"&gt;this&lt;/span&gt;, &lt;span style="color:blue;"&gt;this&lt;/span&gt;.onQueryFailed));&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;My success and failure functions are pretty standard in this case.&amp;#160; I just manually iterate through the results and return the Title and Id.&amp;#160; Otherwise, I display the reason for failure.&lt;/p&gt;  &lt;div style="font-size:10pt;font-family:consolas;background:white;color:black;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;function&lt;/span&gt; onQuerySucceeded() {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; $(&lt;span style="color:#a31515;"&gt;&amp;quot;#results&amp;quot;&lt;/span&gt;).empty();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;var&lt;/span&gt; listInfo = &lt;span style="color:#a31515;"&gt;&amp;#39;&amp;#39;&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;var&lt;/span&gt; listEnumerator = listItems.getEnumerator();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; listInfo += &lt;span style="color:#a31515;"&gt;&amp;quot;&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Id&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Title&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;while&lt;/span&gt; (listEnumerator.moveNext()) {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;var&lt;/span&gt; listItem = listEnumerator.get_current();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; listInfo += &lt;span style="color:#a31515;"&gt;&amp;#39;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;#39;&lt;/span&gt; + listItem.get_item(&lt;span style="color:#a31515;"&gt;&amp;#39;ID&amp;#39;&lt;/span&gt;) + &lt;span style="color:#a31515;"&gt;&amp;#39;&amp;lt;/td&amp;gt;&amp;#39;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; + &lt;span style="color:#a31515;"&gt;&amp;#39;&amp;lt;td&amp;gt;&amp;#39;&lt;/span&gt; + listItem.get_item(&lt;span style="color:#a31515;"&gt;&amp;#39;Title&amp;#39;&lt;/span&gt;) + &lt;span style="color:#a31515;"&gt;&amp;#39;&amp;lt;/td&amp;gt;&amp;#39;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; + &lt;span style="color:#a31515;"&gt;&amp;#39;&amp;lt;/tr&amp;gt;\n&amp;#39;&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; listInfo += &lt;span style="color:#a31515;"&gt;&amp;#39;&amp;lt;/table&amp;gt;&amp;#39;&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; $(&lt;span style="color:#a31515;"&gt;&amp;quot;#results&amp;quot;&lt;/span&gt;).html(listInfo);&lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;function&lt;/span&gt; onQueryFailed(sender, args) {&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; $(&lt;span style="color:#a31515;"&gt;&amp;quot;#results&amp;quot;&lt;/span&gt;).empty();&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; $(&lt;span style="color:#a31515;"&gt;&amp;quot;#results&amp;quot;&lt;/span&gt;).text(&lt;span style="color:#a31515;"&gt;&amp;#39;Request failed. &amp;#39;&lt;/span&gt; + args.get_message() +&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#a31515;"&gt;&amp;#39;\n&amp;#39;&lt;/span&gt; + args.get_stackTrace());&lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;This threw me for a loop for a while, so hopefully this post helps you get started quicker when you build your app.&lt;/p&gt;  &lt;p&gt;Follow me on twitter, &lt;a href="http://twitter.com/coreyroth"&gt;@coreyroth&lt;/a&gt;, if you have any questions and come see me at &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/09/26/speaking-at-sharepoint-conference-2012.aspx"&gt;SPC&lt;/a&gt; if you are going.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=5976" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+11/default.aspx">Visual Studio 11</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2013/default.aspx">SharePoint 2013</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Apps/default.aspx">Apps</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Client+Object+Model/default.aspx">Client Object Model</category></item><item><title>How to: Deploy Metadata Navigation without using code</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/02/09/how-to-deploy-metadata-navigation-without-using-code.aspx</link><pubDate>Wed, 09 Feb 2011 22:37:29 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:4394</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=4394</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2011/02/09/how-to-deploy-metadata-navigation-without-using-code.aspx#comments</comments><description>&lt;p&gt;As someone who focuses mostly on ECM and Search, I am a huge fan of the new Metadata Navigation feature on document libraries in SharePoint 2010.&amp;#160; It provides a great alternative to folders when it comes to navigating your document libraries.&amp;#160; A list administrator can configure Metadata navigation on the document library settings page.&amp;#160; However, I prefer to make changes using CAML or code so that I can deploy them easily to other environments.&amp;#160; Usually, my first choice is with CAML, so I did some digging today and I discovered the trick to deploying your Metadata navigation settings using a SharePoint feature.&lt;/p&gt;  &lt;p&gt;When I first started investigating this, I assumed it might be some new element or attribute inside the schema.xml file of the list.&amp;#160; It turns out my assumption was incorrect.&amp;#160; We actually set this by assigning some XML to the &lt;em&gt;client_MOSS_MetadataNavigationSettings&lt;/em&gt; property on the root folder of the list.&amp;#160; We can assign this value using code, but you know I prefer to use CAML.&amp;#160;&amp;#160; We can use the &lt;em&gt;PropertyBag&lt;/em&gt; element to make this happen.&amp;#160; Before we look at the PropertyBag element itself though, let’s look at the underlying XML.&amp;#160; Let’s take my list here with three items selected for Metadata Navigation: a site column named &lt;em&gt;DocumentType&lt;/em&gt;, the &lt;em&gt;Content Type &lt;/em&gt;of the documents in the library, and the &lt;em&gt;Folders &lt;/em&gt;in the library itself.&amp;#160; Here is what the XML will look like.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;MetadataNavigationSettings&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;SchemaVersion&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;IsEnabled&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;AutoIndex&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;NavigationHierarchies&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;FolderHierarchy&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;HideFoldersNode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;False&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;MetadataField&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;3c6f8f63-0616-437c-80eb-cf7cba0d88cc&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Choice&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;DocumentType&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedDisplayName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;DocumentType&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;MetadataField&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;03e45e84-1992-4d42-9116-26f756012634&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;ContentTypeId&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;ContentTypeId&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedDisplayName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Content Type&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;NavigationHierarchies&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ManagedIndices&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ManagedIndex&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;IndexID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;3c6f8f63-0616-437c-80eb-cf7cba0d88cc&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;IndexFieldName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;DocumentType&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;IndexFieldID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;3c6f8f63-0616-437c-80eb-cf7cba0d88cc&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ManagedIndices&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;MetadataNavigationSettings&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The first line seems to always be the same.&amp;#160; It enables the Metadata Navigation and it will take care of automatically adding new index columns when &lt;em&gt;AutoIndex &lt;/em&gt;is set to true.&amp;#160; The &lt;em&gt;NavigationHierarchies&lt;/em&gt; section actually defines which fields will be used for Metadata navigation.&amp;#160; If you want to navigate by folders, add a &lt;em&gt;FolderHierarchy&lt;/em&gt; element and set &lt;em&gt;HideFoldersNode&lt;/em&gt; to false.&amp;#160; If you set it to true, folder navigation will not be present.&amp;#160; The &lt;em&gt;MetadataField&lt;/em&gt; element defines which fields to use for navigation.&amp;#160; You need the GUID for each site column to include.&amp;#160; You can get this from your list’s schema.xml file.&amp;#160; You then need to specify the &lt;em&gt;FieldType&lt;/em&gt;.&amp;#160; Remember that it only supports Single-value Choice (Choice),&amp;#160; Managed Metadata (TaxonomyFieldType) , and Content Type (ContentTypeId) field types.&amp;#160; You then need to specify the field name in the &lt;em&gt;CachedName&lt;/em&gt; field and then you can customize the display name as you see fit with &lt;em&gt;CachedDisplayName&lt;/em&gt;.&amp;#160; The last thing to note here is that you have to create a Managed Index for any choice fields you add.&amp;#160; This is why you see a &lt;em&gt;ManagedIndex&lt;/em&gt; element with the &lt;em&gt;DocumentType&lt;/em&gt; field.&amp;#160; Set the &lt;em&gt;IndexId &lt;/em&gt;and &lt;em&gt;IndexFieldId &lt;/em&gt;attributes equal to the Id of the field.&lt;/p&gt;  &lt;p&gt;At this point, we are ready to assign this XML to the the &lt;em&gt;client_MOSS_MetadataNavigationSettings &lt;/em&gt;property.&amp;#160; We need to encode the above XML, because it is being stored inside an attribute of another XML document.&amp;#160; Here is what your elements.xml file would look like.&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a31515;"&gt;xml&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;encoding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;?&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Elements&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PropertyBag&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Url&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Shared Documents&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;ParentType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Folder&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;RootWebOnly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;FALSE&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Property&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;client_MOSS_MetadataNavigationSettings&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Value&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:red;"&gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;MetadataNavigationSettings SchemaVersion=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; IsEnabled=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; AutoIndex=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&amp;amp;gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;NavigationHierarchies&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;FolderHierarchy HideFoldersNode=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; /&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;MetadataField FieldID=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;3c6f8f63-0616-437c-80eb-cf7cba0d88cc&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; FieldType=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;Choice&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; CachedName=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;DocumentType&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; CachedDisplayName=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;DocumentType&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; /&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;MetadataField FieldID=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;03e45e84-1992-4d42-9116-26f756012634&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; FieldType=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;ContentTypeId&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; CachedName=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;ContentTypeId&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; CachedDisplayName=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;Content Type&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; /&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;/NavigationHierarchies&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;ManagedIndices&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;ManagedIndex IndexID=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;3c6f8f63-0616-437c-80eb-cf7cba0d88cc&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; IndexFieldName=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;DocumentType&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; IndexFieldID=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;3c6f8f63-0616-437c-80eb-cf7cba0d88cc&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; /&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;ManagedIndex IndexID=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;d31655d1-1d5b-4511-95a1-7a09e9b75bf2&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; IndexFieldName=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;Editor&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; IndexFieldID=&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt;d31655d1-1d5b-4511-95a1-7a09e9b75bf2&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:blue;"&gt; /&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;/ManagedIndices&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;/MetadataNavigationSettings&lt;/span&gt;&lt;span style="color:red;"&gt;&amp;amp;gt;&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PropertyBag&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Elements&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;It’s kind of hard to read the contents of the &lt;em&gt;Property &lt;/em&gt;element, but it is just the encoded version of the XML above.&amp;#160; As for the &lt;em&gt;PropertyBag &lt;/em&gt;element, you just specify the relative &lt;em&gt;Url&lt;/em&gt; to the document library on your site.&amp;#160; In this case, it’s &lt;em&gt;Shared Documents&lt;/em&gt;.&amp;#160; Always set &lt;em&gt;ParentType&lt;/em&gt; to &lt;em&gt;Folder&lt;/em&gt; and &lt;em&gt;RootWebOnly&lt;/em&gt; to &lt;em&gt;false&lt;/em&gt;.&amp;#160; At this point, you can activate this feature after you have deployed your document library and it will enable the Metadata navigation.&amp;#160; Here is what the Metadata Navigation settings page looks like.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/MetadataNavigationSettings_3EE38935.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="MetadataNavigationSettings" border="0" alt="MetadataNavigationSettings" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/MetadataNavigationSettings_thumb_75050184.png" width="733" height="150" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here is what my document library looks like with the navigation enabled.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/MetadataNavigationExpanded_45D315ED.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="MetadataNavigationExpanded" border="0" alt="MetadataNavigationExpanded" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/MetadataNavigationExpanded_thumb_254BD63B.png" width="190" height="154" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It’s pretty easy to set this up as you can see.&amp;#160; Keep in mind that if you set this value, it will overwrite any values previously stored.&amp;#160; This includes any Key Filters or Indexes that might already be present on the list.&amp;#160; &lt;/p&gt;  &lt;p&gt;Speaking of Key Filters, we can add them to the document library using the &lt;em&gt;client_MOSS_MetadataNavigationSettings &lt;/em&gt;as well.&amp;#160; Let’s look at some more XML.&amp;#160; In this case, I am adding key filters for &lt;em&gt;DocumentType&lt;/em&gt;, &lt;em&gt;All Tags&lt;/em&gt;, and &lt;em&gt;Modified By &lt;/em&gt;(editor).&lt;/p&gt;  &lt;div style="font-family:consolas;background:white;color:black;font-size:10pt;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;MetadataNavigationSettings&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;SchemaVersion&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;IsEnabled&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;AutoIndex&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;KeyFilters&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;MetadataField&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;3c6f8f63-0616-437c-80eb-cf7cba0d88cc&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Choice&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;DocumentType&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedDisplayName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;DocumentType&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;MetadataField&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;23f27201-bee3-471e-b2e7-b64fd8b7ca38&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;TaxonomyFieldTypeMulti&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;TaxKeyword&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedDisplayName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;All Tags&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;MetadataField&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;d31655d1-1d5b-4511-95a1-7a09e9b75bf2&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;FieldType&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;User&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Editor&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;CachedDisplayName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Modified By&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;KeyFilters&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ManagedIndices&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ManagedIndex&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;IndexID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;d31655d1-1d5b-4511-95a1-7a09e9b75bf2&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;IndexFieldName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Editor&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;IndexFieldID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;d31655d1-1d5b-4511-95a1-7a09e9b75bf2&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ManagedIndices&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;MetadataNavigationSettings&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The elements are pretty similar to that of the &lt;em&gt;NavigationHierarchies&lt;/em&gt; element.&amp;#160; You add one &lt;em&gt;MetadataField &lt;/em&gt;element for each field you want with the same attributes as before.&amp;#160; However, a few more fields types are supported such as Person or Group (User).&amp;#160; It also recognizes Enterprise Keywords through the use of the All Tags (TaxonomyFieldMulti) filter.&amp;#160; You can also do Date and Time fields as well as Number fields too.&amp;#160; I also added the ManagedIndex field for &lt;em&gt;Editor&lt;/em&gt; (the Modified By filter).&amp;#160; You can probably leave the indexes out since &lt;em&gt;AutoIndex &lt;/em&gt;is true, but if you run into issues, you can add them manually as you see above.&amp;#160; You can deploy &lt;em&gt;KeyFilters &lt;/em&gt;and &lt;em&gt;NavigationHierarchies &lt;/em&gt;elements at the same time.&amp;#160; You’ll need to encode the XML again just as you did before.&amp;#160; When you activate the feature, you’ll have Key Filters enabled on your document library.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/MetadataKeyFilters_3D6F4096.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="MetadataKeyFilters" border="0" alt="MetadataKeyFilters" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/MetadataKeyFilters_thumb_1871801D.png" width="224" height="189" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Using the PropertyBag element, you can easily add metadata navigation to your document libraries.&amp;#160; This is a great alternative to defining these settings using code.&amp;#160; &lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=4394" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Feature/default.aspx">Feature</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ECM/default.aspx">ECM</category></item><item><title>Deploying an External List via Feature using CAML #sp2010</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/25/deploying-an-external-list-via-feature-using-caml-sp2010.aspx</link><pubDate>Thu, 25 Feb 2010 19:33:13 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:2817</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=2817</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/25/deploying-an-external-list-via-feature-using-caml-sp2010.aspx#comments</comments><description>&lt;p&gt;I’ve been talking a lot about external lists lately as you may know.&amp;#160; They are so easy to create with SharePoint Designer, but you wouldn’t really deploy them to production that way would you?&amp;#160; Of course not!&amp;#160; We need a feature.&amp;#160; At first, you might think generating all of that CAML might be too difficult, but remember we can use the Save Site as Template page to generate a .wsp file for us.&amp;#160; Using this we can import it into Visual Studio and learn what CAML we need to use.&lt;/p&gt;  &lt;p&gt;We’re going to start with the same external list from yesterday.&amp;#160; You can build your own using SharePoint Designer as described in my &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/02/it-s-easy-to-configure-an-external-list-with-business-connectivity-services-bcs-in-sharepoint-foundation-2010.aspx"&gt;BCS&lt;/a&gt; post.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListFeatureList_2418B653.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="ExternalListFeatureList" border="0" alt="ExternalListFeatureList" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListFeatureList_thumb_0E6E57E9.png" width="415" height="119" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once you are happy with your list, go to Site Settings –&amp;gt; Save Site as Template.&amp;#160; Fill in the fields and it will save a solution package in your solution gallery of your site collection.&amp;#160; Save the .wsp file to disk and we’re ready to begin.&amp;#160; Once you have your solution package, open Visual Studio 2010, create a new project, and use the Import SharePoint Solution Package project template.&amp;#160; You will be prompted for what site to use and where the package file is.&amp;#160; On the next step, you will be prompted for what you want to import.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListSolutionImport_1F0652D7.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="ExternalListSolutionImport" border="0" alt="ExternalListSolutionImport" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListSolutionImport_thumb_2F321AD0.png" width="414" height="329" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The solution package has every site column, content type, page, list, etc, on the site so there is a lot to sift through.&amp;#160; However, the only thing we really need is the list instance in question (in my case Products).&amp;#160; You will want to unselect everything else as it will take forever to import if you don’t.&lt;/p&gt;  &lt;p&gt;Quick Tip: There isn’t a select all button, so press Ctrl+A, and then unclick a checkbox to deselect everything.&lt;/p&gt;  &lt;p&gt;On the next step you will get a warning about dependencies.&amp;#160; Go ahead and just say yes and your project will import.&amp;#160; Your project will likely have a bunch of stuff you don’t really care about.&amp;#160; All that you really need is what it is created in List Instances.&amp;#160; Your list instance might look something like this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListFeatureSolutionExplorer_4CC3F5CF.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="ExternalListFeatureSolutionExplorer" border="0" alt="ExternalListFeatureSolutionExplorer" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListFeatureSolutionExplorer_thumb_4055D2A6.png" width="157" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;At this point, I created a new project because I want to keep things clean.&amp;#160; Create a new project and create a new List Definition.&amp;#160; At this point, you will have a schema file and two new elements files.&amp;#160; The elements.xml file with the list template can be deleted since I don’t want users creating new versions of this list.&amp;#160; Before we start digging into the CAML that is required to make an external list work, let’s go back and look at SharePoint Designer so we can remember what our application definition looked like.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListFeatureApplicationDefinition_5EC0138F.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="ExternalListFeatureApplicationDefinition" border="0" alt="ExternalListFeatureApplicationDefinition" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListFeatureApplicationDefinition_thumb_3641317B.png" width="269" height="319" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The reason I show you this is because these values we’re going to see when we take a look at our elements.xml file.&amp;#160; Here is the file that came from the site export.&lt;/p&gt;  &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;?&lt;span style="color:#cc7832;"&gt;xml&lt;/span&gt; &lt;span style="color:silver;"&gt;version&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;1.0&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;encoding&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;utf-8&lt;/span&gt;&amp;quot;?&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;ListInstance&lt;/span&gt; &lt;span style="color:silver;"&gt;FeatureId&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{00bfea71-9549-43f8-b978-e47e54a10600}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;TemplateType&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;600&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Title&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Products&lt;/span&gt;&amp;quot; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:silver;"&gt;Description&lt;/span&gt;=&amp;quot;&amp;quot; &lt;span style="color:silver;"&gt;Url&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lists/Products&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;CustomSchema&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Files\Lists\Products\Schema.xml&lt;/span&gt;&amp;quot; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:silver;"&gt;HyperlinkBaseUrl&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://sp2010/Test&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;RootWebOnly&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;DataSource&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Entity&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Products&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;EntityNamespace&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://sp2010/test&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;LobSystemInstance&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;bcs_test&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;SpecificFinder&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Read Item&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;DataSource&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;ListInstance&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;/&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt;&amp;gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;A couple of things to note here.&amp;#160; First, the &lt;em&gt;TemplateType &lt;/em&gt;is &lt;strong&gt;600&lt;/strong&gt;.&amp;#160; We can only presume this is the list template id for an external list.&amp;#160; The other thing of note is the new &lt;em&gt;DataSource&lt;/em&gt; element.&amp;#160; This was not in previous versions of SharePoint.&amp;#160; As you might notice here, these values correspond to what we see on the external content type.&amp;#160; This is what you will change should you decide to rename the entity in or change the LobSystemInstance name.&amp;#160; This XML is highly useable in our own feature, but I am going to remove some of the unnecessary attributes such as FeatureId and CustomSchema.&amp;#160; I’m also going to give it a new Title so that we know this is a different list.&amp;#160; Here is what my new elements.xml looks like.&lt;/p&gt;  &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;?&lt;span style="color:#cc7832;"&gt;xml&lt;/span&gt; &lt;span style="color:silver;"&gt;version&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;1.0&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;encoding&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;utf-8&lt;/span&gt;&amp;quot;?&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;ListInstance&lt;/span&gt; &lt;span style="color:silver;"&gt;TemplateType&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;600&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Title&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Products - Deployed by Feature&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Description&lt;/span&gt;=&amp;quot;&amp;quot; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:silver;"&gt;Url&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lists/ProductsDeployedByFeature&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;HyperlinkBaseUrl&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://sp2010/Test&lt;/span&gt;&amp;quot; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:silver;"&gt;RootWebOnly&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;DataSource&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Entity&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Products&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;EntityNamespace&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://sp2010/test&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;LobSystemInstance&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;bcs_test&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;SpecificFinder&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Read Item&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;DataSource&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;ListInstance&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;/&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt;&amp;gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Honestly, I think I can get rid of HyperLinkBaseUrl as well.&amp;#160; It doesn’t seem to matter though, I deployed it to a few other sites and it seems to work fine.&amp;#160; Now let’s take a look schema.xml.&amp;#160; It’s actually pretty small which is nice compared to the files we were used to in the past.&lt;/p&gt;  &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;?&lt;span style="color:#cc7832;"&gt;xml&lt;/span&gt; &lt;span style="color:silver;"&gt;version&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;1.0&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;encoding&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;utf-8&lt;/span&gt;&amp;quot;?&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;List&lt;/span&gt; &lt;span style="color:silver;"&gt;Title&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Products&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Direction&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;none&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Url&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lists/Products&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;BaseType&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;600&lt;/span&gt;&amp;quot; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:silver;"&gt;FolderCreation&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;DisableAttachments&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Catalog&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;RootWebOnly&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:silver;"&gt;SendToLocation&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;|&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ImageUrl&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;/_layouts/images/itgen.gif&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;xmlns:ows&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Microsoft SharePoint&lt;/span&gt;&amp;quot; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:silver;"&gt;xmlns:spctf&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/v3/contenttype/forms&lt;/span&gt;&amp;quot; &lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;MetaData&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;ContentTypes&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;ContentType&lt;/span&gt; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0x01&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Item&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Group&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;List Content Types&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Description&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Create a new list item.&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;FeatureId&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{695b6570-a48b-4a8e-8ea5-26ea7fc1d162}&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Folder&lt;/span&gt; &lt;span style="color:silver;"&gt;TargetName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Item&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRefs&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{c042a256-787d-4a6f-8a8a-cf6ab767f12d}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;ContentType&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{fa564e0f-0c70-4ab9-b863-0177e6ddd247}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Title&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Required&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ShowInNewForm&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ShowInEditForm&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;FieldRefs&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;XmlDocuments&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;XmlDocument&lt;/span&gt; &lt;span style="color:silver;"&gt;NamespaceURI&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/v3/contenttype/forms&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FormTemplates&lt;/span&gt; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/v3/contenttype/forms&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Display&lt;/span&gt;&amp;gt;ListForm&amp;lt;/&lt;span style="color:#cc7832;"&gt;Display&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Edit&lt;/span&gt;&amp;gt;ListForm&amp;lt;/&lt;span style="color:#cc7832;"&gt;Edit&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;New&lt;/span&gt;&amp;gt;ListForm&amp;lt;/&lt;span style="color:#cc7832;"&gt;New&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;FormTemplates&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;XmlDocument&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;XmlDocuments&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;ContentType&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;ContentTypes&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Fields&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;BDC Identity&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Hidden&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;BdcIdentity&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/v3&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;BdcIdentity&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Text&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Name&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Hidden&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Name&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/v3&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Name&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Text&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Id&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Hidden&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Id&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/v3&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Id&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Integer&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Color&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Hidden&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Color&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/v3&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Color&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Text&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Description&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Hidden&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Description&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/v3&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Description&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Text&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Price&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Hidden&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Price&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/v3&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Price&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Decimal&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;Fields&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Forms&lt;/span&gt; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Views&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;View&lt;/span&gt; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Products Read List&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;DefaultView&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;BaseViewID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;1&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;HTML&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;MobileView&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;MobileDefaultView&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ImageUrl&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;/_layouts/images/generic.png&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;XslLink&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;main.xsl&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;WebPartZoneID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Main&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;WebPartOrder&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;1&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Url&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Read List.aspx&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SetupPath&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;pages\viewpage.aspx&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;XslLink&lt;/span&gt;&amp;gt;main.xsl&amp;lt;/&lt;span style="color:#cc7832;"&gt;XslLink&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Method&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Read List&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Query&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;OrderBy&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Name&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;OrderBy&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;Query&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;ViewFields&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Name&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ListItemMenu&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;LinkToItem&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Id&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Color&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Description&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Price&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;ViewFields&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;RowLimit&lt;/span&gt; &lt;span style="color:silver;"&gt;Paged&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot;&amp;gt;30&amp;lt;/&lt;span style="color:#cc7832;"&gt;RowLimit&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Aggregations&lt;/span&gt; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Off&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;View&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;Views&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;MetaData&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;/&lt;span style="color:#cc7832;"&gt;List&lt;/span&gt;&amp;gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;As you can see it’s pretty clean.&amp;#160; It again uses the Type of 600.&amp;#160; In the ContentTypes section, it does define a regular list item, but it doesn’t actually add any of the fields from the external list there.&amp;#160; The Fields element has a field defined for each field in my external content type.&amp;#160; As you can see there is nothing special about the way they are defined.&amp;#160; The only one of note is the BdcIdentity field which I assume is required to keep track of the ID that ties back to the BCS itself.&amp;#160; The View is surprisingly clean as well.&amp;#160; The &lt;em&gt;XslLink&lt;/em&gt; and &lt;em&gt;Method&lt;/em&gt; elements are new.&amp;#160; I assume we can use XslLink to customize how the view is rendered, but I didn’t actually see a main.xsl file generated in the solution package anywhere.&amp;#160; The Method element I can only assume corresponds to the name of the finder method &lt;em&gt;Read List&lt;/em&gt; which we have seen above.&amp;#160; The rest is pretty simple.&amp;#160; It just has a FieldRef for each column in my external content type.&amp;#160; &lt;/p&gt;  &lt;p&gt;I can pretty much use the Schema.xml file as is.&amp;#160; I did change the Title and Url attributes at the top but that is it.&amp;#160; At this point my new feature to deploy this is ready to go.&amp;#160; Here is what it looks like in Visual Studio.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListNewSolutionExplorer_349065A7.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="ExternalListNewSolutionExplorer" border="0" alt="ExternalListNewSolutionExplorer" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListNewSolutionExplorer_thumb_1A4FFC83.png" width="187" height="185" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Deploy your solution and have it activate your feature.&amp;#160; The new list won’t show up automatically in the navigation on the side, but it will be there.&amp;#160; Just go to the URL directly or view the lists on your site to get there.&amp;#160; Here it is on my new site.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListOnNewSite_6B1E10EB.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="ExternalListOnNewSite" border="0" alt="ExternalListOnNewSite" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListOnNewSite_thumb_5DD787D8.png" width="464" height="207" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;As you can see it’s really not that hard to deploy an external list to another site properly using a feature.&amp;#160; Now, you might have noticed there are a few other elements.xml files generated when we did the site export.&amp;#160; One stores specific values in the property bag of the list.&amp;#160; This we did not want because we don’t really want to copy those internal properties.&amp;#160; The other deals with the forms of the list.&amp;#160; It uses the BinarySerializedWebPart which scares me a bit, so I haven’t messed with it much.&amp;#160; If you are just using default forms you don’t need to worry about it.&amp;#160; In a future post, I’ll try seeing if I can deploy some InfoPath forms along with the list, but I figured that deserves its own post.&lt;/p&gt;  &lt;p&gt;Also, one other thing to note.&amp;#160; If you are deploying your external content type to another server, you can do that in the same manner as you did in SharePoint 2007.&amp;#160; Just export the application definition and import it on the new server.&amp;#160; You can also use the Export Application Model button in SharePoint designer on the External Content Types list.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListExportApplicationModel_0E1E5C8F.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="ExternalListExportApplicationModel" border="0" alt="ExternalListExportApplicationModel" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ExternalListExportApplicationModel_thumb_1F228A72.png" width="107" height="89" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I hope this helps when you look to move lists into production.&amp;#160; This technique of exporting and importing will also work with regular lists of course.&amp;#160; Just remember, friends don’t let friends deploy lists without a feature.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=2817" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Feature/default.aspx">Feature</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+Designer/default.aspx">SharePoint Designer</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SP2010+Beta/default.aspx">SP2010 Beta</category></item><item><title>Does Save Site as Template preserve Version History in sp2010?</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/11/does-save-site-as-template-preserve-version-history-in-sp2010.aspx</link><pubDate>Thu, 11 Feb 2010 22:18:26 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:2731</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=2731</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/11/does-save-site-as-template-preserve-version-history-in-sp2010.aspx#comments</comments><description>&lt;p&gt;It looks like the answer is no.&amp;#160; When you click the &lt;em&gt;Include Content&lt;/em&gt; checkbox on the Save as Template page, it looks like only the latest version of documents and lists items are included in the .wsp file.&amp;#160; I ran a few tests and here is what I saw.&amp;#160; Consider the following document with its history from the source site.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SaveSiteSourceDocumentHistory_3B1E6CCD.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="SaveSiteSourceDocumentHistory" border="0" alt="SaveSiteSourceDocumentHistory" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SaveSiteSourceDocumentHistory_thumb_473FE6F4.png" width="411" height="277" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After I export the site, install and activate the solution on a new site collection and then use the Create Site menu to create a new instance of my site template, only the latest version of the document is there.&amp;#160; Now, I’m not complaining as this is already a great step in the right direction and it really does make moving things around between servers easier. In the screenshot below though, you can see that only the latest version is present.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SaveSiteDestinationDocumentHistory_58B047CC.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="SaveSiteDestinationDocumentHistory" border="0" alt="SaveSiteDestinationDocumentHistory" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SaveSiteDestinationDocumentHistory_thumb_785F2194.png" width="420" height="184" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;   &lt;p&gt;I’m not really sure why it creates two versions of the document (with different file sizes even), but I am sure there is a reason.&amp;#160; If you haven’t use Save Site as Template, be sure and check it out.&amp;#160; It does export content (including documents). Your documents are packaged up in the .wsp and use the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/06/02/how-to-deploy-a-page-using-a-feature.aspx"&gt;module element&lt;/a&gt; to copy them via feature to your document library.&amp;#160; Here is what your package looks like in Visual Studio 2010.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SaveSitePackage_25E04158.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="SaveSitePackage" border="0" alt="SaveSitePackage" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SaveSitePackage_thumb_309D98AD.png" width="189" height="177" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;As you can tell from my string of posts lately, I am really excited about the Save Site as Template functionality.&amp;#160; We all would have killed to have it in WSS3.&amp;#160; It really is a great way to see how things are built behind the scenes to using CAML.&lt;/p&gt;&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=2731" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SP2010+Beta/default.aspx">SP2010 Beta</category></item><item><title>Using the PropertyBag element to assign properties to Items in SharePoint 2010</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/11/using-the-propertybag-element-to-assign-properties-to-items-in-sharepoint-2010.aspx</link><pubDate>Thu, 11 Feb 2010 21:43:28 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:2730</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=2730</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/11/using-the-propertybag-element-to-assign-properties-to-items-in-sharepoint-2010.aspx#comments</comments><description>&lt;p&gt;When the NDA dropped, I mentioned how you could use the new &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/20/writing-to-the-property-bag-using-caml-in-sp2010.aspx"&gt;PropertyBag&lt;/a&gt; element in a feature to write values into the property bag of a site.&amp;#160; I already thought that was going to be incredibly useful, but it turns out the power of this new element is even greater than I first realized.&amp;#160; At the time I noticed that the PropertyBag element had a Url attribute but I didn’t understand what it was used for at the time.&amp;#160; Now I do.&amp;#160; As I mentioned yesterday, I have been experimenting with exporting sites as .wsp files and I discovered that you can use this to write to properties of an existing list item.&amp;#160; Take a look at the following example, that I grabbed from the file it generated when exporting my site.&amp;#160; This applies properties to default.master.&lt;/p&gt;  &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;?&lt;span style="color:#cc7832;"&gt;xml&lt;/span&gt; &lt;span style="color:silver;"&gt;version&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;1.0&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;encoding&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;utf-8&lt;/span&gt;&amp;quot;?&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;PropertyBag&lt;/span&gt; &lt;span style="color:silver;"&gt;Url&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;_catalogs/masterpage/default.master&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ParentType&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;File&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;RootWebOnly&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;HyperlinkBaseUrl&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://sp2010/Test&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_charset&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;utf-8&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_candeleteversion&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;true&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_modifiedby&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;SHAREPOINT\system&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_cachedneedsrewrite&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;false&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_level&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;1&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_rtag&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;rt:7CDE768C-FCE1-46E8-9165-FDA564419D9A@00000000002&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_cachedbodystyle&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:silver;"&gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;body scroll=&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;yes&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt; onload=&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;BLOCKED SCRIPTif (typeof(_spBodyOnLoadWrapper) != &amp;#39;undefined&amp;#39;) _spBodyOnLoadWrapper();&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&amp;amp;gt;&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_title&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:silver;"&gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;asp:ContentPlaceHolder id=&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;PlaceHolderPageTitle&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt; runat=&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;server&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;/&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;gt;&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;UIVersion&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;3&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_parserversion&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;14.0.0.4536&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_cachedhastheme&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;false&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_foldersubfolderitemcount&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_hasdefaultcontent&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;true&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_setuppathversion&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;4&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_metainfoversion&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;2&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_canmaybeedit&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;true&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_generator&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Microsoft SharePoint&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_etag&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;{7CDE768C-FCE1-46E8-9165-FDA564419D9A},2&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_cachedtitle&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:silver;"&gt;&amp;amp;lt;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;asp:ContentPlaceHolder id=&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;PlaceHolderPageTitle&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt; runat=&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;server&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;quot;&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;/&lt;/span&gt;&lt;span style="color:silver;"&gt;&amp;amp;gt;&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_contentversion&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_progid&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;SharePoint.WebPartPage.Document&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_timelastmodified&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;2010-02-10T16:12:34Z&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_sourcecontrolversion&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;V1.0&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_timecreated&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;2010-02-10T16:12:34Z&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_folderitemcount&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_docstoretype&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;ContentTypeId&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0x01010500CE60EDAC92E8C942BFB82AF8AFC4A5F4&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_filesize&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;29039&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_sourcecontrolcookie&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;fp_internal&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_author&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;SHAREPOINT\system&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_setuppath&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;global\default.master&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_metatags&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;GENERATOR Microsoft\ SharePoint progid SharePoint.WebPartPage.Document HTTP-EQUIV=Content-Type text/&lt;/span&gt;&lt;span style="color:#a5c25c;"&gt;html;\ charset=utf-8 HTTP-EQUIV=Expires 0&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_replid&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;rid:{7CDE768C-FCE1-46E8-9165-FDA564419D9A}&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_docstoreversion&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;2&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;Property&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_cachedcustomprops&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Value&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;vti_title&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;/&lt;span style="color:#cc7832;"&gt;PropertyBag&lt;/span&gt;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;/&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt;&amp;gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;As you can see the relative URL of the file is specified along with a separate attribute indicating the base URL it came from.&amp;#160; You also need to specify something for &lt;em&gt;ParentType&lt;/em&gt;.&amp;#160; For now I know that you can specify &lt;em&gt;File&lt;/em&gt; or &lt;em&gt;Folder&lt;/em&gt; there (although I am guessing it might take Item or something like that).&lt;/p&gt;  &lt;p&gt;Now for the most part all of these properties listed above are internal properties that you would never care about setting, but as you guessed you can specify your own properties as well.&amp;#160; The export site as template functionality does its best to export everything it can and that includes internal properties as well.&amp;#160; This is pretty interesting feature and I think it could remove the need to write a lot of code in my future.&amp;#160; &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/05/12/code-samples-from-our-caml-vs-api-talk-at-tulsa-sharepoint-interest-group.aspx"&gt;@SPKyle&lt;/a&gt; might still want to write code to store properties on list items, but I will take a pass. :)&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=2730" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Feature/default.aspx">Feature</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SP2010+Beta/default.aspx">SP2010 Beta</category></item><item><title>Deploying Relational Lists using CAML in SharePoint 2010</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/10/deploying-relational-lists-using-caml-in-sharepoint-2010.aspx</link><pubDate>Wed, 10 Feb 2010 20:46:20 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:2726</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=2726</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/10/deploying-relational-lists-using-caml-in-sharepoint-2010.aspx#comments</comments><description>&lt;p&gt;One of my favorite new features in SharePoint 2010 is the ability to have lists relate to each other and the fact that you can maintain referential integrity.&amp;#160; Now, I am sure there are at least 50 posts out there already that show you how to do this using the UI.&amp;#160; The UI is great, but you are a developer and that means you might want to actually deploy these lists elsewhere someday.&amp;#160; Now I have to admit, using the save site as template feature is great for moving sites and content around but you may want a more granular deployment of a pair of lists in a single feature.&amp;#160; The cool thing is the save site as template feature is extremely useful for discovering the underlying CAML to build things in SharePoint which is how I discovered relational lists work today.&amp;#160; This &lt;a href="http://weblogs.asp.net/soever/archive/2009/10/19/sharepoint-2010-site-exporting-as-wsp-solution-part-1.aspx"&gt;post&lt;/a&gt; has some great screenshots of how to export a site template as a wsp.&lt;/p&gt;  &lt;p&gt;For today’s example, I have a list of categories and a list of products.&amp;#160; The products list has a lookup column which references the categories list.&amp;#160; Here is what the products list looks like.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/RelationalLists_48814495.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="RelationalLists" border="0" alt="RelationalLists" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/RelationalLists_thumb_11C3E991.png" width="458" height="142" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;On this view, you can see that I am linking to the Categories list and I am displaying the Id and Description from that list.&amp;#160; Here is how my lookup column is defined.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/RelationalListsLookupColumn_3825CCDC.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="RelationalListsLookupColumn" border="0" alt="RelationalListsLookupColumn" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/RelationalListsLookupColumn_thumb_05C1F95D.png" width="220" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Creating a list with CAML in SharePoint 2010 is really not much different than in previous versions.&amp;#160; In order to set up this lookup column, we need to look at the Schema.xml of the Products list.&amp;#160; It turns out that the column that the user chooses is still a lookup column but so are the additional fields.&amp;#160; They just have additional attributes defined.&amp;#160; Let’s look at the definition of the lookup column the user interacts with first.&lt;/p&gt;  &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lookup&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Required&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;EnforceUniqueValues&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;List&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lists/Categories&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ShowField&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Title&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;UnlimitedLengthInDocumentLibrary&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Indexed&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;RelationshipDeleteBehavior&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Cascade&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{c59b5e18-54c2-408a-a231-b88c3e939e90}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{$ListId:Lists/Products;}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;RowOrdinal&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;I got this schema by doing an export as mentioned above.&amp;#160; There are a few things you might notice here.&amp;#160; The list name and SourceID refer to the lists by URL instead of a hardcoded Id.&amp;#160; The value of Indexed is also set to true.&amp;#160; This is because relational lists require indexed columns.&amp;#160; You also get prompted to index the column when you set it up through the UI.&amp;#160; The last thing to note is the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.sprelationshipdeletebehavior(office.14).aspx"&gt;RelationshipDeleteBehavior&lt;/a&gt; attribute.&amp;#160; It can have a value of Cascade, Restrict, or none.&amp;#160; This corresponds to relationship behavior you see in the UI screenshot above.&lt;/p&gt;  &lt;p&gt;The additional fields from the parent list are also lookup fields.&amp;#160;&amp;#160; They just have a few key differences.&lt;/p&gt;  &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lookup&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category:ID&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;List&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lists/Categories&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;WebId&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;8c918dd2-ef1f-4822-b3d2-f587d622d203&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ShowField&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;ID&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;FieldRef&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;c59b5e18-54c2-408a-a231-b88c3e939e90&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ReadOnly&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;UnlimitedLengthInDocumentLibrary&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{2264d6b5-7001-40e1-b295-236b9965c833}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{$ListId:Lists/Products;}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category_x003a_ID&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category_x003a_ID&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lookup&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category:Description&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;List&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lists/Categories&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;WebId&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;8c918dd2-ef1f-4822-b3d2-f587d622d203&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ShowField&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Description&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;FieldRef&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;c59b5e18-54c2-408a-a231-b88c3e939e90&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ReadOnly&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;UnlimitedLengthInDocumentLibrary&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{a0ab273e-5989-42ba-950d-3add1c1025e0}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{$ListId:Lists/Products;}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category_x003a_Description&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category_x003a_Description&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;First, the FieldRef attribute has the Id of the first lookup field we defined.&amp;#160; This is what ties them together.&amp;#160; The second thing is that the ShowField attribute refers to the name of the field in the lookup list.&amp;#160; The last thing to note is that they are marked as readonly.&amp;#160; One more thing to point out is that the static name is encoded with x003a which is the color you see in the DisplayName.&amp;#160; This is also used in the FieldRef elements you will also have on any ConentType element thats uses these fields in your schema.xml.&amp;#160; For example.&lt;/p&gt;  &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{c59b5e18-54c2-408a-a231-b88c3e939e90}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Required&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{2264d6b5-7001-40e1-b295-236b9965c833}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category_x003a_ID&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ReadOnly&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;FieldRef&lt;/span&gt; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{a0ab273e-5989-42ba-950d-3add1c1025e0}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category_x003a_Description&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Category:Description&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ReadOnly&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;You might not see much value in this post yet, but I think you might in the future.&amp;#160; The tools to work with SharePoint have improved greatly, but you still will need to work with some CAML from time to time I believe.&amp;#160; You may not be building it from scratch any more, but it is still good to know your way around it.&amp;#160; As a developer I often get frustrated when I run into posts showing how to do something through the UI when I really need to know how to build something declaratively or programmatically.&amp;#160; Hopefully this will be helpful.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=2726" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+Designer/default.aspx">SharePoint Designer</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint+2010/default.aspx">SharePoint 2010</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SP2010+Beta/default.aspx">SP2010 Beta</category></item><item><title>SPQuery Error: Microsoft.SharePoint.SPException was unhandled by user code.  Cannot complete this action. Please try again.</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/26/spquery-error-microsoft-sharepoint-spexception-was-unhandled-by-user-code-cannot-complete-this-action-please-try-again.aspx</link><pubDate>Tue, 26 Jan 2010 21:05:09 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:2247</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=2247</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/26/spquery-error-microsoft-sharepoint-spexception-was-unhandled-by-user-code-cannot-complete-this-action-please-try-again.aspx#comments</comments><description>&lt;p&gt;When I get an error, I like to blog about it.&amp;#160; Especially when the error gives you no useful information whatsoever.&amp;#160; Now, you can get the above error in a variety of ways, but the one I am going to discuss today is when using SPQuery.&amp;#160; I inherited some code that had some CAML queries in it and I could not figure out what the cause was at first.&amp;#160; When I called SPList.GetItems(SPQuery), I would receive something like the following.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Microsoft.SharePoint.SPException was unhandled by user code     &lt;br /&gt;&amp;#160; Message=&amp;quot;Cannot complete this action.\n\nPlease try again.&amp;quot;      &lt;br /&gt;&amp;#160; Source=&amp;quot;Microsoft.SharePoint&amp;quot;      &lt;br /&gt;&amp;#160; ErrorCode=-2147467259      &lt;br /&gt;&amp;#160; StackTrace:      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback(String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pSchemaCallback)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at Microsoft.SharePoint.SPListItemCollection.get_Count()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at Samson.P2S.SharePoint.Services.Synchronization.P2S_SynchronizationService.&amp;lt;&amp;gt;c__DisplayClass6.&amp;lt;GetInventoryChecklist&amp;gt;b__4() in C:\Projects\SamsonTFS\P2S\P2S_V0\Samson.P2S.SharePoint.Services.Synchronization\P2S_SynchronizationService.asmx.cs:line 166      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at Microsoft.SharePoint.SPSecurity.&amp;lt;&amp;gt;c__DisplayClass4.&amp;lt;RunWithElevatedPrivileges&amp;gt;b__2()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)      &lt;br /&gt;&amp;#160; InnerException: System.Runtime.InteropServices.COMException      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Message=&amp;quot;Cannot complete this action.\n\nPlease try again.&amp;quot;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Source=&amp;quot;&amp;quot;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ErrorCode=-2147467259      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StackTrace:      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemDataWithCallback(String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pSchemaCallback)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; at Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback(String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pSchemaCallback)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; InnerException:&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;The cause is actually simple.&amp;#160; My CAML query was malformed.&amp;#160; Specifically my where clause was not nested properly.&amp;#160; The previous developer put three conditions in an and clause and that simply does not work.&amp;#160; A COM exception though?&amp;#160; Really? Wouldn’t it have just been better if it validated the query first and gave us a nice error message such as the following?&lt;/p&gt;  &lt;p&gt;&lt;em&gt;CAML query is malformed.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;That would be too nice I guess.&amp;#160; Anyhow, if you get this when querying, start looking at that query.&amp;#160; While, I am here, I’ll remind you if you copy the query from CAML Query Builder, to remove the Query element.&amp;#160; If you can’t figure it out and first, go back to the CAML query building tool of your choice and start executing the query there and comparing it to the one you have.&amp;#160; You should be up and running in no time.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=2247" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Error/default.aspx">Error</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category></item><item><title>Enabling Content Approval on a List using CAML</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/08/enabling-content-approval-on-a-list-using-caml.aspx</link><pubDate>Thu, 08 Oct 2009 22:16:42 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:991</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=991</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/10/08/enabling-content-approval-on-a-list-using-caml.aspx#comments</comments><description>&lt;p&gt;I’ve always liked the power of CAML because it allows me to create so much in SharePoint without ever having to write a line of code.&amp;#160; However, there really isn’t enough examples out there, so I like writing posts like these that focus on doing something very specific with a list.&amp;#160; &lt;a href="http://www.dotnetmafia.com/blogs/kylekelin"&gt;@SPKyle&lt;/a&gt; would say just write some code to do that, but that’s not my style, so I did some digging through the SDK and some experimentation and I figured out how to do it.&amp;#160; Of course there isn’t an attribute called EnableContentApproval.&amp;#160; So, the first thing we have to figure out is what CAML calls content approval.&amp;#160; It turns out CAML refers to this as moderation.&amp;#160; We’ll add this to the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/08/21/sharepoint-to-api-translation-guide.aspx"&gt;SharePoint UI to API translation guide&lt;/a&gt;.&amp;#160; Looking at the List element, I find two attributes &lt;em&gt;ModeratedList&lt;/em&gt; and &lt;em&gt;ModeratedType&lt;/em&gt;.&amp;#160; The description of the both is quite similar, so I decide to try them out one at a time.&amp;#160; I find that setting &lt;em&gt;ModeratedList &lt;/em&gt;works but setting &lt;em&gt;ModeratedType&lt;/em&gt; does nothing.&amp;#160; No idea why there is two attributes.&amp;#160; Maybe one is deprecated.&amp;#160; Here is what a List element line would like in your schema.xml.&lt;/p&gt;   &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;List&lt;/span&gt; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;BaseType&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;DisableAttachments&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;True&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;EnableContentTypes&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;True&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;MyList&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;OrderedList&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;False&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;QuickLaunchUrl&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;True&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Title&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;My List&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;10001&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;VersioningEnabled&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;False&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Url&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lists/MyList&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Id&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;ed65344b-0399-4c34-8265-de0c2d193165&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ModeratedList&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;I then go take a look at the list versioning settings of my newly created list, and everything looks good.&amp;#160; Note, if you want to turn on versioning, you can use the &lt;em&gt;VersioningEnabled &lt;/em&gt;attribute that you see above.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ContentApproval_1CD38DFE.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="ContentApproval" border="0" alt="ContentApproval" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/ContentApproval_thumb_1DABF3E8.png" width="543" height="65" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Again, I set the &lt;em&gt;ModeratedList&lt;/em&gt; attribute in the List element of the Schema.xml.&amp;#160; Before I set it on the schema.xml file, I noticed that the &lt;em&gt;ListTemplate&lt;/em&gt; element that you use in your elements.xml file had an attribute &lt;em&gt;EnableModeration.&amp;#160; &lt;/em&gt;The SDK states this can be used to turn on moderation as well.&amp;#160; However, when using it I find that it does not work.&amp;#160; If I set it to true or false it does not work and does not seem to override I set in the schema.xml file.&amp;#160; Anyhow, if you ever need to turn on content approval and don’t feel like writing code, I hope this helps.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=991" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Feature/default.aspx">Feature</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category></item><item><title>Error: Reference to undeclared namespace: ‘ns1’ when trying to create a custom Document Information Panel</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/09/29/error-reference-to-undeclared-namespace-ns1-when-trying-to-create-a-custom-document-information-panel.aspx</link><pubDate>Tue, 29 Sep 2009 21:40:31 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:982</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=982</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/09/29/error-reference-to-undeclared-namespace-ns1-when-trying-to-create-a-custom-document-information-panel.aspx#comments</comments><description>&lt;p&gt;I’ve been chasing this particular error for a little while and thought I would take the time to share my experience and how to resolve it.&amp;#160; The scenario I had is I have a custom content type with several custom site columns.&amp;#160; I generated the CAML for my content type and site columns using &lt;a href="http://spsource.codeplex.com"&gt;SPSource&lt;/a&gt;.&amp;#160; When I clicked on the Create a new custom template button, I received the following error (or one similar).&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3"&gt;&lt;font color="#000000"&gt;&lt;font face="Calibri"&gt;&lt;em&gt;propertySchema0.xsd#/schema/element[1][@name = &amp;#39;properties&amp;#39;]/complexType[1]/sequence[1]/element[1][@name = &amp;#39;documentManagement&amp;#39;]/complexType[1]/all[1]/element[1]           &lt;p&gt;&lt;/p&gt;         &lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3"&gt;&lt;font color="#000000"&gt;&lt;font face="Calibri"&gt;&lt;em&gt;Reference to undeclared namespace prefix: &amp;#39;ns1&amp;#39;.           &lt;p&gt;&lt;/p&gt;         &lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;p&gt;As with all InfoPath errors, this is completely useless.&amp;#160; After many attempts at trying to figure out this issue, I noticed that I could create a new Lookup Column and a new Content Type using the SharePoint UI and not receive this error.&amp;#160; I then busted out the Imtech Fields Explorer and as far as I could tell all of the properties were just about the same.&amp;#160; However, I noticed one difference in the SchemaXML property.&amp;#160; My Field element did not have a SourceId but the column created through the UI did.&amp;#160; It’s value was set to the Id of the web hosting the site column.&amp;#160; I knew I couldn’t set it to that and so I remembered in the past I had always set the SourceId of the field element as seen below.&lt;/p&gt;    &lt;p&gt;&lt;em&gt;SourceID=”http://schemas.microsoft.com/sharepoint/v3”&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;This got me closer, the content types and site columns deployed correctly and the SchemaXML had a SourceID in it.&amp;#160; However, when I tried to create a Document Information Panel this time, I got this new lovely error.&lt;/p&gt; &lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3"&gt;&lt;font color="#000000"&gt;&lt;font face="Calibri"&gt;&lt;em&gt;InfoPath has encountered an error.&amp;#160; The operation failed.           &lt;p&gt;&lt;/p&gt;         &lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="3"&gt;&lt;font color="#000000"&gt;&lt;font face="Calibri"&gt;&lt;em&gt;Catastrophic failure           &lt;p&gt;&lt;/p&gt;         &lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Once again, thanks InfoPath team for such useful error information.&amp;#160; After further investigation, I discovered I needed to set the StaticName attribute as well.&amp;#160; I simply set this to match the Name attribute I had and everything works now.&amp;#160; It’s strange how the content type can work completely everywhere else, but in InfoPath it’s very picky.&amp;#160; Here is what a complete working Field element might look like for you.&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;background:black;"&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;lt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#cc7832;font-size:13pt;"&gt;Field&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:silver;font-size:13pt;"&gt;Type&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;=&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#a5c25c;font-size:13pt;"&gt;Text&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;quot; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:silver;font-size:13pt;"&gt;DisplayName&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;=&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#a5c25c;font-size:13pt;"&gt;MyField&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;quot; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:silver;font-size:13pt;"&gt;Required&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;=&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#a5c25c;font-size:13pt;"&gt;FALSE&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;quot; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:silver;font-size:13pt;"&gt;MaxLength&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;=&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#a5c25c;font-size:13pt;"&gt;255&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;quot; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:silver;font-size:13pt;"&gt;Group&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;=&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#a5c25c;font-size:13pt;"&gt;My Field Group&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;quot; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:silver;font-size:13pt;"&gt;ID&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;=&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#a5c25c;font-size:13pt;"&gt;{2E6858a5-6ae2-409f-8492-fa15c39821c8}&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;quot; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:silver;font-size:13pt;"&gt;Name&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;=&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#a5c25c;font-size:13pt;"&gt;MyField&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;quot; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:silver;font-size:13pt;"&gt;SourceID&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;=&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#a5c25c;font-size:13pt;"&gt;&lt;a href="http://schemas.microsoft.com/sharepoint/v3"&gt;&lt;font color="#0000ff"&gt;http://schemas.microsoft.com/sharepoint/v3&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;quot; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:silver;font-size:13pt;"&gt;StaticName&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;=&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:#a5c25c;font-size:13pt;"&gt;MyField&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:consolas;color:white;font-size:13pt;"&gt;&amp;quot; /&amp;gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;I mentioned above the issue I had was with a Lookup column but I quickly discovered that this was happening with all of my columns and had nothing to do with the lookup.&amp;#160; SPSource has saved me a ton of time, but this is just another minor thing to look out with the tool.&amp;#160; I logged an issue on CodePlex to see if we can get these two attributes added to the Site Column export.&amp;#160; If you aren’t customizing Document Information Panels, then there is nothing to worry about with the exported CAML, but if you are be sure and add these two attributes.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=982" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Feature/default.aspx">Feature</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/InfoPath/default.aspx">InfoPath</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SPSource/default.aspx">SPSource</category></item><item><title>Using CAML to deploy a lookup column via Feature</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/09/02/using-caml-to-deploy-a-lookup-column-via-feature.aspx</link><pubDate>Wed, 02 Sep 2009 21:47:49 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:962</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=962</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/09/02/using-caml-to-deploy-a-lookup-column-via-feature.aspx#comments</comments><description>&lt;p&gt;This week, I needed to deploy lookup columns to some of my lists and as usual I wanted to avoid writing code at all costs.&amp;#160; As some of you may know, &lt;a href="http://www.dotnetmafia.com/blogs/kylekelin/default.aspx"&gt;Kyle Kelin&lt;/a&gt; and I &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/05/12/code-samples-from-our-caml-vs-api-talk-at-tulsa-sharepoint-interest-group.aspx"&gt;debate&lt;/a&gt; this topic often as he prefers a code approach.&amp;#160; I figured it had to be possible with CAML, but many claimed it was not even possible.&amp;#160; A few approaches showed up out there involving using code to modify the elements.xml file with your GUID, but that just wasn’t going to cut it for me.&amp;#160; One popular post on the topic by &lt;a href="http://blogs.msdn.com/joshuag/archive/2008/03/14/add-sharepoint-lookup-column-declaratively-through-caml-xml.aspx"&gt;Josh Gaffey&lt;/a&gt;, started me in the right direction, but there were a few hurdles I ran into as I was trying to implement it.&amp;#160; It would create the list, show the content type, and site columns, but when I tried to create a new item, the lookup column was not there.&amp;#160; The basic technique is that you specify the path to the list in the form of (Lists/MyListName) in the &lt;em&gt;List &lt;/em&gt;attribute of the &lt;em&gt;Field&lt;/em&gt; element in both your schema.xml file of your document library template as well as the definition of the site column.&amp;#160; The first thing I learned here is that you cannot simply omit declaring site columns and a content type out and go with list level columns.&amp;#160; It simply will not work (no idea why).&lt;/p&gt;  &lt;p&gt;   &lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt; Here is how I ended up getting everything to work.&amp;#160; I created my initial lists, content types, and site columns through the SharePoint UI.&amp;#160; I then used &lt;a href="http://spsource.codeplex.com/"&gt;SPSource&lt;/a&gt; (seriously a great tool) to export the content type, site columns, and lists (both the source list and the one that contained the lookup column).&amp;#160; My goal was to deploy these items to another site collection.&amp;#160;&amp;#160; I recommend creating separate features for your content types and the list definition.&amp;#160; This way you can ensure the content type is deployed first.&amp;#160; To export your content type / site columns, create a new stub feature.xml file as described on their site and then create an .spsource file with just the content type in it like this (no need to specify columns).&lt;/p&gt;   &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;ContentType&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Test&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;/&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt;&amp;gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;In my example, my content type was called &lt;em&gt;Test&lt;/em&gt;.&amp;#160; Create a separate feature folder for your list template and instance.&amp;#160; Create another feature.xml and an .spsource file for the list which looks something like this.&amp;#160; My list is also named &lt;em&gt;Test&lt;/em&gt; in this case.&lt;/p&gt;   &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;ListTemplate&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Test&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;/&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt;&amp;gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;SPSource does a good job when it exports my list definition and properly specifies the list using a path instead of a guid in my lookup column as shown below (from schema.xml). &lt;/p&gt;   &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lookup&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;DocumentCategory&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Required&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;List&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lists/Categories&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ShowField&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Title&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;UnlimitedLengthInDocumentLibrary&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Group&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;My Group&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{9266e0fa-ae49-438c-acdc-73063684ac8f}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;SourceID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{50b253e5-e90e-4781-8fce-cece417b185e}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;StaticName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;DocumentCategory&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;DocumentCategory&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Customization&lt;/span&gt;=&amp;quot;&amp;quot; &lt;span style="color:silver;"&gt;ColName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;int1&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;RowOrdinal&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;0&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;We don’t actually have to change a thing in this file.&amp;#160; What I did have to change is the List attribute of the file it generated for my site columns.&amp;#160; As Josh’s post above stated, we have to change the &lt;em&gt;List&lt;/em&gt; attribute from a GUID to the path of the list.&amp;#160; His post also mentioned you might want to set the PrependId attribute but I have since learned that this is only used when you are using the &lt;em&gt;LookupMulti &lt;/em&gt;type (although I can’t remember the source I got this from).&lt;/p&gt;   &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Field&lt;/span&gt; &lt;span style="color:silver;"&gt;Type&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lookup&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;DisplayName&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;DocumentCategory&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Required&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;TRUE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;List&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Lists/Categories&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ShowField&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;Title&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;UnlimitedLengthInDocumentLibrary&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;FALSE&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Group&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;My Group&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;ID&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;{9266e0fa-ae49-438c-acdc-73063684ac8f}&lt;/span&gt;&amp;quot; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;DocumentCategory&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;At this point you can deploy your site columns, content type, and then custom list (in that order) and if all goes well you will be able to create a new item of that content type with the lookup column functioning.&amp;#160; One thing to note, if you get this wrong, your list will behave oddly.&amp;#160; One thing I noticed is that it won’t turn on content types for the list when that happens.&amp;#160; If this is happening go back and check your work.&amp;#160; Another thing people mentioned is that the source list for the lookup column has to exist before you create the lookup column.&amp;#160; This in fact is not true.&amp;#160; It will work and it will display a drop down list for the lookup column, but it will be empty of course since the list does not exist.&lt;/p&gt;  &lt;p&gt;Along the way I figured out a few other things.&amp;#160; When I was trying to figure this out, I was trying to just create the content type and then manually add it to the list via the UI.&amp;#160; Doesn’t work.&amp;#160; If you try to add a content type with a lookup column defined in this way to an existing list, you will get the following error.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Exception from HRESULT: 0x80040E07 at Microsoft.SharePoint.Library.SPRequestInternalClass.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd)      &lt;br /&gt;at Microsoft.SharePoint.Library.SPRequest.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;The only way to get the content type associated with the list is via CAML when it is created.&amp;#160; Another odd thing is that the lookup column never shows it is bound to the other list correctly.&amp;#160; Here is what the source lookup column looked like.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SharePointLookupColumnSource_13F82363.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="SharePointLookupColumnSource" border="0" alt="SharePointLookupColumnSource" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SharePointLookupColumnSource_thumb_659E9DB5.png" width="261" height="189" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice where it says &lt;em&gt;Get information from, &lt;/em&gt;the name of the list is present.&amp;#160; Here is what my copy of the list looks like.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SharePointLookupColumnCopy_65326AC0.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="SharePointLookupColumnCopy" border="0" alt="SharePointLookupColumnCopy" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/SharePointLookupColumnCopy_thumb_04E14489.png" width="265" height="183" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice that the list name is not present.&amp;#160; Strangely enough though, everything works fine in the copy.&amp;#160; This one through me for a loop for a while because it didn’t seem like things weren’t working and as I mentioned above I couldn’t add the content type to a list (nor could I add the column to a content type).&amp;#160; &lt;/p&gt;  &lt;p&gt;As you can see there are few oddities about deploying lookup columns in this manner, but it does work.&amp;#160; &lt;a href="http://twitter.com/spkyle"&gt;@SPKyle&lt;/a&gt; informed me he could have written code to do this hours ago, but I am quite happy that I can deploy things in this manner now.&lt;/p&gt;  &lt;p&gt;   &lt;p&gt;Twitter: &lt;a href="http://twitter.com/coreyroth"&gt;@coreyroth&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=962" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Content+Type/default.aspx">Content Type</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Feature/default.aspx">Feature</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SPSource/default.aspx">SPSource</category></item><item><title>Code Samples from our CAML vs API talk at Tulsa SharePoint Interest Group</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/05/12/code-samples-from-our-caml-vs-api-talk-at-tulsa-sharepoint-interest-group.aspx</link><pubDate>Tue, 12 May 2009 15:36:00 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:903</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=903</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/05/12/code-samples-from-our-caml-vs-api-talk-at-tulsa-sharepoint-interest-group.aspx#comments</comments><description>&lt;p&gt;Last night, &lt;a href="http://www.dotnetmafia.com/blogs/kylekelin/default.aspx"&gt;Kyle Kelin&lt;/a&gt; and I had the opportunity to debate SharePoint provisioning methodologies at the &lt;a href="http://www.tulsadnug.org/DesktopDefault.aspx"&gt;Tulsa SharePoint Interest Group&lt;/a&gt;.&amp;nbsp; We each had to deploy a custom site with site columns, a content type, a list, and pages.&amp;nbsp; Kyle chose the API approach and I went with the CAML approach.&amp;nbsp; We ended up having a good interactive discussion with the group on the pros and cons of going with either approach.&amp;nbsp; I also took a minute to show how &lt;a href="http://twitter.com/jthake"&gt;@jthake&lt;/a&gt;’s &lt;a href="http://spsource.codeplex.com/"&gt;SPSource&lt;/a&gt; can generate CAML for you and the response was great.&amp;nbsp; As promised here is the code samples from the demo last night.&amp;nbsp; Thanks for coming.&lt;/p&gt;
&lt;p&gt;Follow &lt;a href="http://twitter.com/jkkelin"&gt;Kyle&lt;/a&gt; and &lt;a href="http://twitter.com/coreyroth"&gt;I&lt;/a&gt; on twitter.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=903" width="1" height="1"&gt;</description><enclosure url="http://www.dotnetmafia.com/blogs/dotnettipoftheday/attachment/903.ashx" length="1190522" type="application/x-zip-compressed" /><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Presentations/default.aspx">Presentations</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category></item><item><title>Kyle and I are speaking at Tulsa SPIG this Monday</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/05/08/kyle-and-i-are-speaking-at-tulsa-spig-this-monday.aspx</link><pubDate>Fri, 08 May 2009 14:49:21 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:901</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=901</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/05/08/kyle-and-i-are-speaking-at-tulsa-spig-this-monday.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.dotnetmafia.com/kylekelin"&gt;Kyle Kelin&lt;/a&gt; and I are doing our first joint talk together at the &lt;a href="http://www.tulsadnug.org/DesktopDefault.aspx"&gt;Tulsa SharePoint Interest Group&lt;/a&gt; this Monday, May 11th.&amp;#160; We’re going to be talking about Site Provisioning and let the audience decide what they like better: CAML or the API.&amp;#160; I also plan on demonstrating the use of the &lt;a href="http://spsource.codeplex.com/"&gt;SPSource&lt;/a&gt; tool recently release on CodePlex by &lt;a href="http://twitter.com/jthake"&gt;@jthake&lt;/a&gt;.&amp;#160; We start at 6pm at &lt;a href="http://maps.google.com/maps?f=q&amp;amp;source=s_q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=TCC+Northeast,+tulsa,+ok&amp;amp;sll=37.0625,-95.677068&amp;amp;sspn=48.77566,73.037109&amp;amp;ie=UTF8&amp;amp;z=12&amp;amp;iwloc=A"&gt;TCC Northeast&lt;/a&gt; (3727 N. Apache).&amp;#160; We hope to see you there.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jkkelin"&gt;Kyle Kelin&lt;/a&gt; on twitter.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/croth"&gt;Corey Roth&lt;/a&gt; on twitter.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=901" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Presentations/default.aspx">Presentations</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category></item><item><title>My First Experience with SPSource</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/05/04/my-first-experience-with-spsource.aspx</link><pubDate>Mon, 04 May 2009 16:45:36 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:897</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=897</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/05/04/my-first-experience-with-spsource.aspx#comments</comments><description>&lt;p&gt;If you pay attention to twitter at all, today you might have heard about a new tool on CodePlex called &lt;a href="http://spsource.codeplex.com/"&gt;SPSource&lt;/a&gt;.&amp;#160; SPSource is a tool that reverse engineers existing Content Types, Site Columns, Lists and more on an existing SharePoint site.&amp;#160; This isn’t just a re-tweet style post that tells you its out there.&amp;#160; I actually took a few minutes today to try it out and so far I am very impressed.&amp;#160; &lt;a href="http://www.dotnetmafia.com/blogs/kylekelin/default.aspx"&gt;Kyle Kelin&lt;/a&gt; and I have often talked about the need for a better tool that worked better than VSeWSS Solution Generator.&amp;#160; Already, I think this tool is it.&amp;#160; Finally you can design a content type in the UI and be able to extract it easily as a feature.&lt;/p&gt;  &lt;p&gt;Downloading the tool from CodePlex, gives you an installer for the SPSource executable.&amp;#160; The tool is a command line app designed to be executed in a batch file.&amp;#160; To get started with the tool, you need to create a local 12 hive folder.&amp;#160; You can do this inside Visual Studio manually or with a tool like &lt;a href="http://wspbuilder.codeplex.com/"&gt;wspbuilder&lt;/a&gt;.&amp;#160; For my test purposes, I just created a 12 hive folder in a temp directory and started working.&amp;#160; Before you begin, you will need to create a folder to hold your feature as well as a simple feature.xml file.&amp;#160; The contents of the file don’t need to contain much, just some XML for deploying a simple feature.&amp;#160; The next thing you need to do is identify what you want to extract from your SharePoint.&amp;#160; In my case I wanted to extract some content types and a list template.&amp;#160; You then create a special XML file with the .spsource extension.&amp;#160; This uses the same syntax as any elements.xml file, but it is used to specify which items to extract from SharePoint.&amp;#160; The only thing you need to specify is an element such as &lt;em&gt;ContentType&lt;/em&gt; or &lt;em&gt;ListTemplate&lt;/em&gt; and the name.&amp;#160; It then uses this name to look up the resource in SharePoint and extract it.&amp;#160; Here is an example of what it looks like.&lt;/p&gt;  &lt;div style="font-family:consolas;background:black;color:white;font-size:13pt;font-weight:bold;"&gt;   &lt;p style="margin:0px;"&gt;&amp;lt;&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt; &lt;span style="color:silver;"&gt;xmlns&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;ContentType&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;My Test Content Type&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &amp;lt;&lt;span style="color:#cc7832;"&gt;ListTemplate&lt;/span&gt; &lt;span style="color:silver;"&gt;Name&lt;/span&gt;=&amp;quot;&lt;span style="color:#a5c25c;"&gt;My Custom List&lt;/span&gt;&amp;quot; /&amp;gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;lt;/&lt;span style="color:#cc7832;"&gt;Elements&lt;/span&gt;&amp;gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;SPSource will take this information and generate the XML files I need to deploy these items elsewhere.&amp;#160; You run SPSource with the following syntax.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;spsource.exe –designsite &lt;/em&gt;&lt;a href="http://my-moss-server/site"&gt;&lt;em&gt;http://my-moss-server/site&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;When the tool is executed, it will iterate through any subfolders looking for .spsource files.&amp;#160; When it finds them, it will create XML files representing the type of items you request (in my case a ContentType and a ListTemplate).&amp;#160; It will also update the Feature.xml file in that folder to point to any new .XML files it creates.&amp;#160; So far I have found the XML it generates to be very usable and way more accurate than what SPSolGen gives you.&amp;#160; &lt;/p&gt;  &lt;p&gt;This tool is really nice.&amp;#160; I would like to see some more documentation for it, but I am sure that will come as the tool is developed more.&amp;#160; When you first install it, all you are given is a link to the CodePlex site in your start menu, so you are left a little bit wondering what to do next.&amp;#160; I would love to see more command line options such as just passing it a URL and it extracts the list template.&amp;#160; One thing I noticed is that it didn’t extract the ItemEventReceivers definition I had on my content type.&amp;#160; I am not complaining though since this tool already has the power to save me a ton of time in the future.&lt;/p&gt;  &lt;p&gt;Great work &lt;a href="http://twitter.com/jthake/"&gt;@jthake&lt;/a&gt; and everyone else that worked on it.&amp;#160; Microsoft should have provided a better tool to do this years ago.&amp;#160; I am glad you all stepped up to fill in the gap.&lt;/p&gt;  &lt;p&gt;Follow me on &lt;a href="http://twitter.com/coreyroth"&gt;twitter&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=897" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Feature/default.aspx">Feature</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SPSource/default.aspx">SPSource</category></item><item><title>Using CAML to add Web Parts to an existing page</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/09/15/using-caml-to-add-web-parts-to-an-existing-page.aspx</link><pubDate>Mon, 15 Sep 2008 21:04:18 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:682</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=682</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/09/15/using-caml-to-add-web-parts-to-an-existing-page.aspx#comments</comments><description>&lt;p&gt;In the past when I thought of how to do this, I tended to over analyze it a bit.&amp;nbsp; I always assumed there was something special in how you do this, but in reality, it is not much different than adding web parts to a new page.&amp;nbsp; I am not sure if this is the best way to do it and it only works in some cases, but it&amp;#39;s a start and maybe somebody else can help out.&amp;nbsp; The main thing I was trying to avoid was having to write code in a feature receiver to accomplish this.&amp;nbsp; In today&amp;#39;s example, we are going to assume I have a page called default.aspx on a site and it has a web part zone called &lt;em&gt;Left &lt;/em&gt;(like many default page templates do).&amp;nbsp; To make this happen, I basically write CAML that is just like if I was creating a new page.&amp;nbsp; This includes getting a copy of a default.aspx page (any one will do that has similar names for web part zones) into a new feature.&amp;nbsp; In this case, I am using the default.aspx file from the STS site template located at &lt;em&gt;12\TEMPLATE\SiteTemplates\sts&lt;/em&gt;.&amp;nbsp; In my elements file, I start by adding a Module and File block like below.&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Module&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;DWS&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Url&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Path&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;dws&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;File&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Url&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;default.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;IgnoreIfAlreadyExists&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;TRUE&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;The module &lt;em&gt;Name&lt;/em&gt; you specify is &lt;em&gt;DWS&lt;/em&gt; (which I believe is the name of the list that pages are stored in).&amp;nbsp; The &lt;em&gt;Path&lt;/em&gt; is specified as dws as well assuming I stored my local default.aspx in a folder of that name.&amp;nbsp; You can choose to use a path or not.&amp;nbsp; It shouldn&amp;#39;t matter.&amp;nbsp; I then specify the filename with the &lt;em&gt;IgnoreIfAlreadyExists&lt;/em&gt; attribute set to true.&amp;nbsp; I believe this results in SharePoint not trying to create a new page if one of that name already exists.&amp;nbsp; After you have your file element it is just a matter of specifying your web parts as usual.&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;AllUsersWebPart&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;WebPartZoneID&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Left&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;WebPartOrder&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;![CDATA[&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WebPart xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2&amp;quot;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Assembly&amp;gt;Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;lt;/Assembly&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TypeName&amp;gt;Microsoft.Office.Server.Search.WebControls.SearchPagingWebPart&amp;lt;/TypeName&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Title&amp;gt;$Resources:spscore,SearchPagingWP_Title;&amp;lt;/Title&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Description&amp;gt;$Resources:spscore,SearchPagingWPWP_Desc;&amp;lt;/Description&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;PartOrder&amp;gt;1&amp;lt;/PartOrder&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FrameType&amp;gt;None&amp;lt;/FrameType&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AllowMinimize&amp;gt;true&amp;lt;/AllowMinimize&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AllowRemove&amp;gt;true&amp;lt;/AllowRemove&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;IsVisible&amp;gt;true&amp;lt;/IsVisible&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/WebPart&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:gray;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;]]&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;AllUsersWebPart&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Every time the feature is activated, it will add the web parts you specify to the file that you specify.&amp;nbsp; This ends up working pretty well, but keep in mind there is nothing built in to delete your web parts off of your web page.&amp;nbsp; If you want to do that, you are going to have to write code in a feature receiver to remove the web parts (a post which I still need to write).&amp;nbsp; Anyhow, I guess what I am saying is that it really isn&amp;#39;t any more complicated than adding web parts to a new page.&amp;nbsp; I am not sure if this is the best way to do it so if you have a better idea be sure to leave a comment.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=682" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/WebPart/default.aspx">WebPart</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/CAML/default.aspx">CAML</category></item></channel></rss>