【发布时间】:2016-03-30 11:57:55
【问题描述】:
我无法根据 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 中定义的视图。
我不知道如何使用客户端对象模型从列表模板添加视图
感谢您的支持
【问题讨论】:
标签: c# sharepoint sharepoint-2013 sharepoint-clientobject