【问题标题】:Sharepoint: Check if item exists in a sharepoint list subfolder via webservices?Sharepoint:通过网络服务检查项目是否存在于共享点列表子文件夹中?
【发布时间】:2010-12-12 23:03:30
【问题描述】:

我最初的问题here 回答了如何检查列表中是否存在项目,但这不适用于列表中子文件夹中的项目。

无论项目存储在哪个子文件夹中,如何检查项目是否存在?

如果做不到这一点,我如何检查项目是否存在,即使这意味着以某种方式将子文件夹值传递给查询?

以下代码有效,但不会查看子文件夹:

private bool attachmentLinkItemDoesntExist(string attachmentName)
{
    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<Document><Query><Where><Contains><FieldRef Name=\"Title\" /><Value Type=\"Text\">" +  this.downloadedMessageID + "_" + attachmentName + "</Value></Contains></Where></Query><ViewFields /><QueryOptions /></Document>");
    XmlNode listQuery = doc.SelectSingleNode("//Query");
    XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
    XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
    XmlNode items = this.wsLists.GetListItems(this.AttachmentsListName , string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, null);
    if (items.ChildNodes[1].Attributes["ItemCount"].Value == "0")
    {
        return true;
    }
    else
    {
        return false;
    }
}

【问题讨论】:

    标签: sharepoint wss


    【解决方案1】:

    你需要将作用域设置为递归

    你可以使用对象模型SPQuery.ViewAttributes来做到这一点

    query.ViewAttributes = "Scope=\"Recursive\"";
    

    看起来您正在使用 Web 服务 GetListItems,因此您将在 QueryOptions 中传递此参数

    <QueryOptions>
       <ViewAttributes Scope="Recursive" />
    </QueryOptions>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-09
      • 2012-11-09
      • 1970-01-01
      • 2012-04-22
      • 1970-01-01
      • 2011-07-03
      • 1970-01-01
      相关资源
      最近更新 更多