1

I cant create a List based in a Custom List Template from Sharepoint 2013. The list is created correctly but not contain the views that is defined in the list template.

In my code, first I get the listTemplate:

    ListTemplateCollection ltc = context.Site.GetCustomListTemplates(context.Web);
context.Load(ltc);
context.ExecuteQuery();
ListTemplate listTemplate = ltc.FirstOrDefault(n => n.Name == "name");

Then create the ListCreationInformation object:

ListCreationInformation lc = new ListCreationInformation();
lc.Title = GetNameDocumentLibrary(nombreBibliotecaDocumentos);
lc.TemplateType = listTemplate.ListTemplateTypeKind;
lc.TemplateFeatureId = listTemplate.FeatureId;
lc.QuickLaunchOption = QuickLaunchOptions.DefaultValue;

Then, Add the list to Context Sharepoint

List newList = context.Web.Lists.Add(lc);
newList.ContentTypesEnabled = true;
newList.OnQuickLaunch = true;
newList.Update();
context.ExecuteQuery();

And Finally I Assign the ContentTypes:

List<ContentType> contentTypeCustom = new List<ContentType>();
foreach (ContentType ct in contentTypeColl)
if (ct.Group == "Tipos de contenido personalizados")
newList.ContentTypes.AddExistingContentType(ct);

newList.Update();
context.ExecuteQuery();

But when I Show the configuration of my new list, not have the views that is defined in listTemplate.

I dont know how add the views from list template using client object model

Thanks for your support

1 Answers1

0

Current COM seems not able to create lists from a client-defined custom list template. It looks like the API cannot differentiate the basic list template and the list template inherited from it as they share the same template feature ID.

I suggest you directly create the list from COM.

Reference: https://social.technet.microsoft.com/Forums/en-US/c018867b-d8c3-438a-b3f9-959b6d42fbcc/create-list-using-custom-template-using-the-client-object-model?forum=sharepointdevelopmentprevious

Mario
  • 55
  • 1
  • 8