Watch out for TemplateType when using SPSource to export lists
Posted
Monday, September 21, 2009 9:55 AM
by
CoreyRoth
I can’t continue to reiterate how much time SPSource can save you when it comes to exporting existing lists into usable features, but I found one minor thing to look out for when you are exporting lists. Usually, you can take just about whatever SPSource gives you and redeploy it without having to change a thing, however in the cases of lists you need to look out for the TemplateType attribute otherwise it can cause you problems. Take a look at the XML below from the elements file.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate AllowDeletion="True" AllowEveryoneViewItems="False" BaseType="1" DisplayName="Concepts" Description="" EnableModeration="False" Hidden="False" OnQuickLaunch="True" Name="List1" Type="100" SecurityBits="11" Sequence="110" DocumentTemplate="101" VersioningEnabled="True" />
<ListInstance FeatureId="cac9f905-9380-4252-8307-d2cffb6f0c1f" Id="c5dd284f-fb59-44b9-bcfd-b4f779d9fd8d" TemplateType="100" Title="List1" Url="Lists/Lists1" />
<ListTemplate AllowDeletion="True" AllowEveryoneViewItems="False" BaseType="1" DisplayName="Regionals" Description="" EnableModeration="False" Hidden="False" OnQuickLaunch="True" Name="Regionals" Type="101" SecurityBits="11" Sequence="110" DocumentTemplate="101" VersioningEnabled="True" />
<ListInstance FeatureId="cac9f905-9380-4252-8307-d2cffb6f0c1f" Id="631657f0-b687-4b61-ad28-13ea1140cd21" TemplateType="101" Title="List2" Url="Lists/List2" />
</Elements>
As you can see I have a ListTemplate and ListElement element for two different lists (list1 and list2). If you look further you notice that the Type attribute on the ListTemplate elements is 100 and 101 respectively. The issue is that 100 is already reserved for a generic list and 101 is a document library so deploying this file can cause general weirdness in SharePoint. Here is the list of stock list template IDs in case you were curious.
As you may guess this is pretty easy to resolve. Just pick a new number that is not reserved for your Type. I believe the best practice recommends starting at 10000. After you change the Type attribute, be sure and change the TemplateType attribute of the ListInstance element to match it. That is all there is to it. If you haven’t checked out SPSource yet be sure to, the next time you need to export sites, lists, content types or site columns. It can save you a ton of time.