【问题标题】:Cannot Create List based in a Custom Templates that contains Custom Views using COM无法使用 COM 在包含自定义视图的自定义模板中创建列表
【发布时间】: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


    【解决方案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

    【讨论】:

      猜你喜欢
      • 2016-04-30
      • 1970-01-01
      • 2017-03-20
      • 1970-01-01
      • 1970-01-01
      • 2014-10-15
      • 1970-01-01
      • 1970-01-01
      • 2016-12-22
      相关资源
      最近更新 更多