【发布时间】:2016-06-19 22:23:24
【问题描述】:
我无法使用以下 sn-p 创建列表内容类型。它会抛出带有附加信息的 ServerException - “站点内容类型已添加到此列表中。”
var list = clientContext.Web.Lists.GetByTitle("sometitle");
var documentCT = clientContext.Web.ContentTypes.GetById("0x0101");
clientContext.Load(list,l=> l.ContentTypes);
clientContext.Load(documentCT);
clientContext.ExecuteQuery();
var test = new ContentTypeCreationInformation(){
Name = "TestCT", ParentContentType =documentCT };
list.ContentTypes.Add(test);
list.Update();
clientContext.ExecuteQuery();
基本上,我想创建一个列表内容类型,其父项是“文档”CT。
【问题讨论】:
-
您得到的错误表明内容类型已创建并附加到列表中,一遍又一遍地运行它会抛出此错误,您是说您已经运行了脚本和内容类型存在但不附加到列表或内容类型甚至没有被创建?
-
是的,没有创建内容类型。
-
你在哪里检查?网站设置、内容类型?
-
在网站内容类型中是的。请注意我的目标是添加列表内容类型...
标签: sharepoint csom