Mar 22, 2011

GetCustomListTemplates returns 0 values

One of my colleague encountered this issue where he was trying to create list on feature activation based on a custom list template uploaded to the list template gallery.
We tried different ways to check why the GetCustomListTemplates method of SPSite retunred empty values even if there are custom list templates uploaded to the gallery.

It is because we didn't set the Version property while uploading the templates via Feature. SharePoint 2010 expects version to be '4' for the list template.
So this did the trick for us:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
<Module Name="TestModule1" Url="_catalogs/lt" List="114">
<File Path="TestModule1\MyList1.stp" Url="MyList1.stp" Type="GhostableInLibrary" IgnoreIfAlreadyExists="FALSE" >
<Property Name="Product Version" Value="4" />

Resolution: Setting the 'Product Version' property of File object in the elements xml file to value '4' allowed us to access that template via GetCustomListTemplates property of SPSite object in SharePoint 2010

1 comment:

  1. There is an issue with SharePoint 2010 where you can not create custom templates if you use the Records Center template as your root web template. If this is the case, GetCustomListTemplates() will always return ZERO.

    Links to more information:

    - Jason