我无法从Sharepoint 2013创建基于自定义列表模板的列表 . 列表已正确创建,但不包含列表模板中定义的视图 .
在我的代码中,首先我得到listTemplate:
ListTemplateCollection ltc = context.Site.GetCustomListTemplates(context.Web);
context.Load(ltc);
context.ExecuteQuery();
ListTemplate listTemplate = ltc.FirstOrDefault(n => n.Name == "name");
然后创建ListCreationInformation对象:
ListCreationInformation lc = new ListCreationInformation();
lc.Title = GetNameDocumentLibrary(nombreBibliotecaDocumentos);
lc.TemplateType = listTemplate.ListTemplateTypeKind;
lc.TemplateFeatureId = listTemplate.FeatureId;
lc.QuickLaunchOption = QuickLaunchOptions.DefaultValue;
然后,将列表添加到Context Sharepoint
List newList = context.Web.Lists.Add(lc);
newList.ContentTypesEnabled = true;
newList.OnQuickLaunch = true;
newList.Update();
context.ExecuteQuery();
最后我分配了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();
但是当我显示我的新列表的配置时,没有listTemplate中定义的视图 .
我不知道如何使用客户端对象模型从列表模板添加视图
感谢您的支持
1 回答
当前的COM似乎无法从客户端定义的自定义列表模板创建列表 . 看起来API无法区分基本列表模板和从其继承的列表模板,因为它们共享相同的模板功能ID .
我建议你直接从COM创建列表 .
参考: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