Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

Creating SharePoint Custom List using a list using a Microsoft.SharePoint.Client.ClientContext object: Lists.Add method from existing Template does not Include Template Content (include content was checked for template)

$
0
0

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?



Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>