开发者

Sharepoint: Check if item exists in a sharepoint list subfolder via webservices?

My original question here answers how to check if an item exists in a list, but this doesn't work for items in sub folders in the list.

How can I check if an item exists, regardless of what subfolder its stored in?

Failing this, how can I check if an item exists , even if this means somehow passing the subfolder value to the query somehow?

Following code works, but will not look in subfolders:

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开发者_如何学JAVA")
    {
        return true;
    }
    else
    {
        return false;
    }
}


You need to set the Scope to Recursive

You can do this using the object model SPQuery.ViewAttributes

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

Looks like you are using the web service GetListItems so you would pass this param in QueryOptions

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜