I'm creating the list based on custom list template. List is creating, but the custom list template is not applied for my list.
ListTemplate template = null;
ListTemplateCollection ltc = context.Site.GetCustomListTemplates(context.Web);
context.Load(ltc);
context.ExecuteQuery();
foreach (ListTemplate t in ltc)
{
if (t.InternalName == "STPDiv.stp")
{
template = t;
break;
}
}
ListCreationInformation info = new ListCreationInformation();
info.Title = "TestCreation";
info.TemplateType = template.ListTemplateTypeKind;
info.TemplateFeatureId = template.FeatureId;
info.QuickLaunchOption = QuickLaunchOptions.DefaultValue;
site.Lists.Add(info);
context.ExecuteQuery();
How can my code be modified to get the custom list applied?
Try this code given below. It should work for you. Let me know if you encounter any problem.
As per Microsoft : ListCreationInformation members
TemplateFeatureId = Gets or sets a value that specifies the feature identifier of the feature that contains the list schema for the new list