0

I want to create list using .stp file which is uploaded in to the list template Gallary.

--> I am using Console application to create list in online site. --> have an any idea how to add list from stp file at online site.

I am not getting custom list using below code.

listTemplate = Context.Web.ListTemplates.First(t => t.ListTemplateTypeKind == TemplateID);

How should i get .stp list template in context ?

Dipen Shah
  • 184
  • 9

1 Answers1

-1

First is just a LINQ query to get the first item.

I assume you are using the Client-Side OM? Did you have explicitely requested Context.Web.ListTemplates (as in: did you ClientContext.Load(ListTemplates)) ? Otherwise it will not be available.

Try this:

 var site = context.Web;
 context.Load(site,s => s.ListTemplates );
 context.ExecuteQuery();

 var listCreationInfo = new ListCreationInformation
 {
       Title = "<Your Title>",
       Description = "<Your Description>"
 };

 var listTemplate = site.ListTemplates.First(lt => lt.Name == "<Your Template Name>");
 listCreationInfo.TemplateFeatureId = listTemplate.FeatureId;
 listCreationInfo.TemplateType = listTemplate.ListTemplateTypeKind;

 site.Lists.Add(listCreationInfo);
 context.ExecuteQuery();
Verthosa
  • 1,671
  • 1
  • 15
  • 37