The code below works assuming you have a list template setup called "GenTasksTemplate".
The problem is that even though the check box to include content was checked during the creation of the template, the task items in the new list do not get populated. What am I missing?
using System; using System.Linq; using Microsoft.SharePoint.Client; protected void createSPlist(object sender, EventArgs e) { ClientContext context = new ClientContext("https://sharepointServer/sites/devcollection/"); var web = context.Web; ListTemplateCollection ltc = context.Site.GetCustomListTemplates(context.Web); ListCollection siteListsColection = web.Lists; context.Load(ltc); context.ExecuteQuery(); ListCreationInformation listCreationInfo = new ListCreationInformation { Title = "New Task from Template", Description = "Tasks created from custom template" }; Microsoft.SharePoint.Client.ListTemplate listTemplate = ltc.First(listTemp => listTemp.Name == "GenTasksTemplate"); listCreationInfo.TemplateFeatureId = listTemplate.FeatureId; listCreationInfo.TemplateType = listTemplate.ListTemplateTypeKind; listCreationInfo.DocumentTemplateType = listTemplate.ListTemplateTypeKind; //listCreationInfo.CustomSchemaXml = siteListsColection.Add(listCreationInfo); context.Load(siteListsColection); context.ExecuteQuery(); }
http://www.net4geeks.com Who said I was a geek?