【问题标题】:"Value Does not Fall within the Expected Range" error is thrown while replying to a Discussion回复讨论时抛出“值不在预期范围内”错误
【发布时间】:2014-09-10 11:24:47
【问题描述】:

我正在使用 SharePoint 客户端对象模型 (CSOM) 使用以下代码回复 Sharepoint Online 2013 网站上的现有讨论

SP.ListItem oListItem = SP.Utilities.Utility.CreateNewDiscussionReply(ctx, parentListItem);
oListItem.Update();
ctx.ExecuteQuery();
oListItem["Body"] = "Reply msg Body.";
oListItem.Update();
ctx.ExecuteQuery();

不过,对于 TeamSite,如果我尝试回复现有讨论,则代码运行成功。

但是,对于 CommunitySite,相同的代码可以成功运行,但是当我尝试加载此讨论列表的所有 ListItems 时,值未在预期范围内,会引发错误。以下是我用来加载所有 ListItems 的代码 sn-p。

SP.CamlQuery camlQuery = new SP.CamlQuery();
camlQuery.ViewXml = "<View Scope=\"RecursiveAll\" />";
listItemCollection = list.GetItems(camlQuery);

ctx.Load(listItemCollection);
ctx.ExecuteQuery(); 

这是一个错误,还是我需要以不同的方式创建讨论及其回复?我使用 v15 和 v16 中的 SharePoint.Client dll 测试了这种行为。

【问题讨论】:

    标签: c# sharepoint sharepoint-clientobject


    【解决方案1】:

    尝试删除递归。

    SP.CamlQuery camlQuery = new SP.CamlQuery();
    listItemCollection = list.GetItems(camlQuery);
    
    ctx.Load(listItemCollection);
    ctx.ExecuteQuery(); 

    【讨论】:

      猜你喜欢
      • 2014-02-10
      • 1970-01-01
      • 2013-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多