When adding a List View web part in a custom Site Definition be careful to define the url correctly. If not, SharePoint returns the following error when creating a site based upon the Site Definition.
Cannot complete this action.
Please try again. at Microsoft.SharePoint.Library.SPRequestInternalClass.ApplyWebTemplate(String bstrUrl, String& bstrWebTemplate, Int32& plWebTemplateId)
at Microsoft.SharePoint.Library.SPRequest.ApplyWebTemplate(String bstrUrl, String& bstrWebTemplate, Int32& plWebTemplateId)
It took me a whole afternoon looking for a solution.
Detailed description
I created a feature with a new Site Definition. To this Site Definition I added a custom task list with display name “Qrm reminders”. The list is a custom list that is deployed as a feature ( 2849AF43-E405-481c-9803-09F55785C214) on the server.
For your reference I also included the definition of a default task list.
1: <List FeatureId="00BFEA71-A83E-497E-9BA0-7A5C597D0107" Type="107"
2: Title="$Resources:core,taskList;"
3: Url="$Resources:core,lists_Folder;/$Resources:core,tasks_Folder;"
4: QuickLaunchUrl="$Resources:core,lists_Folder;/$Resources:core,tasks_Folder;/AllItems.aspx" />
5:
6: <List FeatureId="2849AF43-E405-481c-9803-09F55785C214" Type="10002"
7: Title="QRM Reminders"
8: Url="$Resources:core,lists_Folder;/QrmTasks"
9: QuickLaunchUrl="$Resources:core,lists_Folder;/QrmTasks/AllItems.aspx" >
As you can see in the above code, the list “QRM Reminders” is added. It is based on custom type 10002. I also replaced the resource that defines the name for the list ‘QRMTasks’
Further down in the Site Definition I add a List View web part on the default.aspx page. This List View web part points to the custom list QRMTasks (display name = Qrm Reminders)
1: <View List="Lists/QrmTasks" BaseViewID="1" WebPartZoneID="Right" WebPartOrder="3" />
When creating a site based on this site definition with the List View web part, it returns the following error.
Cannot complete this action.Please try again. at Microsoft.SharePoint.Library.SPRequestInternalClass.ApplyWebTemplate(String bstrUrl, String& bstrWebTemplate, Int32& plWebTemplateId)
Some error information from the SharePoint logs :
Creating list “QRM Reminders” in web “http://wind2003entr2:1100/sites/demoSiteFail” at URL “Lists/QrmTasks”,
Creating default modules at URL “http://wind2003entr2:1100/sites/demoSiteFail” Not enough information to determine a list for module “Default”. Assuming no list for this module.
Failed to find a suitable list for tag in module for file ‘default.aspx’ given List attribute ‘QrmTasks’.
Failed to apply template “ProjectSite#0″ to web at URL “http://wind2003entr2:1100/sites/demoSiteFail”.
Failed to apply template “ProjectSite#0″ to web at URL “http://wind2003entr2:1100/sites/demoSiteFail”, error 0×80004005
Without the List View web part definition, the site and the QrmTasks list are created successfully.
Solution.
It took me a whole afternoon to figure it out. It turned out the url attribute was improperly set.
I specified the list url as: Url=”$Resources:core,lists_Folder;/QrmTasks”. So it would result in Lists/QrmTasks
For some reason the List View web part could not find the “QrmTasks” list on this location. So I simplified the url and deleted the folder ‘Lists’ from the url
1: <List FeatureId="2849AF43-E405-481c-9803-09F55785C214" Type="10002"
2: Title="QRM Reminders"
3: Url="QrmTasks"
4: QuickLaunchUrl="$Resources:core,lists_Folder;/QrmTasks/AllItems.aspx" >
7: ...
6: <View List="QrmTasks" BaseViewID="1" WebPartZoneID="Right" WebPartOrder="3" />
Note: the url attribute of the list definition now only contains QrmTasks.
Basically the list ‘folder’ is removed from the url. After this the Site Definition worked as expected and the List View web part was correctly provisioned on the page.