Take the 2-minute tour ×
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

2 Answers 2

up vote 0 down vote accepted

I know the TemplateFeatureId property looks like it should do what we want, ie. create a list from a given template, but it doesn't.

On this post and this post, on MSDN forums, the accepted answer is that you can't create a list from a list template at all using the client side object model - and that's my experience, too.

share|improve this 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.

I executed above code but it not working. Can you please help....

share|improve this answer
    
Anyone reading this: don't get your hopes up. It only works for built-in list templates, not custom ones. –  johnnycardy Feb 21 at 15:44

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.