Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Creating lists in SharePoint using Managed Client Object Model is rather easy task. Here's how to create a list with SharePoint's custom list template:

ListCreationInformation lci;
List list;

lci = new ListCreationInformation();
lci.Title = title;
lci.Description = description;
lci.TemplateType = (int)ListTemplateType.GenericList;
list = clientContext.Web.Lists.Add(lci);
clientContext.ExecuteQuery();

But what happens if I don't what to use any of the default ListTemplateType templates? What if I have created my own list template and I want to use it in the code to create lists based on it? Please help, thanks.

share|improve this question
I can't comment due to my low rep, but I'd like to know if you ever figured this out. I have looked long and hard for a solution and am yet to find one. – user1913954 Dec 31 '12 at 0:06

1 Answer

I cannot test this because I dont have a dev environment at the moment, but the following should work:

            ListCreationInformation lci;
            List list;

            lci = new ListCreationInformation();
            lci.Title = title;
            lci.Description = description;


            ListTemplate lt = ClientContext.Current.Web.ListTemplates.First(z => z.Name == "MyTemplateName");
            lci.TemplateFeatureId = lt.FeatureId;

            list = clientContext.Web.Lists.Add(lci);
            clientContext.ExecuteQuery();

As per http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listcreationinformation_members.aspx

TemplateFeatureId = Gets or sets a value that specifies the feature identifier of the feature that contains the list schema for the new list.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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