SubPointSolutions / spmeta2

SharePoint artifact provision for .NET platform. Supports SharePoint Online, SharePoint 2019, 2016 and 2013 via CSOM/SSOM.
http://subpointsolutions.com/spmeta2
133 stars 56 forks source link

Unable to provision custom List Template #1107

Closed DaniCorretja closed 6 years ago

DaniCorretja commented 6 years ago

How can I create a custom List Template and deploy it with SPMeta2? I couldn't find any documentation or example of it. Is it even possible? I've been able to create a new List Template but I cannot find how to provision it and then use it to create lists.

SubPointSupport commented 6 years ago

Hey @DaniCorretja, thanks for raising this up.

Yes, it is possible to deploy list with SPMeta2 using either TemplateType or TemplateName properties.

ListDefinition.TemplateType is an integer value corresponding toS harePoint's built-in list templates. With custom list templates, ListDefinition.TemplateName should be used (this is an internal template name).

Now, the question is how to fetch your custom list template name and how to deploy it in the first place. If list template is already there, then it would be a matter of using browser or SharePoint manager or custom scripts to figure out custom list template name.

If list template isn't there, and is a part of sandbox or ".wsp" solution, then there are a few options - you still can have to deploy this solution so that custom list template would be available on the site, and then use custom list template name in SPMeta2. Another option it to use ".stp" files putting them into List Templates library.

Finally, we've got regression testing examples on some list definition provision scenarios. That might be of help:

https://github.com/SubPointSolutions/spmeta2/blob/master/SPMeta2/SPMeta2.Regression.Tests/Impl/Scenarios/ListScenariosTest.cs

Check out "CanDeploy_List_From_STPListTemplate" test. We've got "M2Template.stp" which is delivered to the ListTemplates library via ModuleDefinition (simple file provision). Once there, we can use "ListDefinition.TemplateName = "M2Template" to create a list out of custom list template.

Hope that help to figure out the right scenarios for your case. Let us know if that helps.

DaniCorretja commented 6 years ago

@SubPointSupport thank you for the quick answer, really useful and complete. That solved my issue so you can close this issue 👍

SubPointSupport commented 6 years ago

Too easy, @DaniCorretja. Nice to hear that it works well for you!