首页 文章

无法基于包含使用COM的自定义视图的自定义模板创建列表

提问于
浏览
1

我无法从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 回答

相关问题