I have created a custom list definition which simplies creates a new list using "Document Library" list.

I created another Custom Document Library and was wondering if there is any way I can create a Custom Document Library in ONET.XML (site definition) and then use the same list for creating the site.

Currently, I am using following code,

<List FeatureId="GUID ID" Type="91001" Title="DocumentLibrary" Url="DocumentLibrary" />

Now it does work for Document Library because its already created and available in the list, however If i put my list name which is "Custom Document Library"

I get this error,

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)

which defiantly because list hasn't been created yet, however I have a list feature activated and I can create a new list using the list template.

1 Answer 1


Not actually answering your question, but here is a suggestion. Always develop your list templates and list instances in features.

Then bind your onet.xml to your features. If you want to allow you list templates to be created only in your custom site, simple "hide" the feature.

The advantage of this technique is that it's easier to "debug", because you can concentrate on a single feature using Visual Studio. When it's ready, simply push the feature id in onet.xml.

The other advantage of this technique is that you can later create a second site template and reuse your list template.

If I'm right, you can take a look at some Out of box templates build on this model (Enterprise Wiki and Publishing site are creating some common lists, which cannot be created from the new list wizard).

  • Hi Steve, thanks for suggestion, but I have a list feature for custom document Library already and thats how i made this custom list, but dont know how can I bind it with my onet.xml and how it gonna be created in custom site definition :) May 15, 2012 at 14:07
  • You can also create a feature for the list instance in order to test the feature containing the list instance
    – Steve B
    May 15, 2012 at 15:21
  • 1
    To activate your feature automatically in a custom site definition add it inside <SiteFeatures> or <WebFeatures> in you ONET.XML depending on scope May 15, 2012 at 19:01
  • You guys said well I didn't needed to create a template, it gets created itself when i bind it in the configuration, the problem was, I was giving it Wrong URL :) May 16, 2012 at 5:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.