2009-11-04 67 views
0

我原來的問題here解答瞭如何檢查一個項目是否存在於一個列表中,但是這對列表中的子文件夾中的項目不起作用。Sharepoint:通過webservices檢查項目是否存在於sharepoint list子文件夾中?

如何檢查項目是否存在,而不管其存儲在哪個子文件夾中?

失敗了,我該如何檢查一個項是否存在,即使這意味着某種方式將子文件夾值傳遞給查詢以某種方式?

下面的代碼工作,但不會在子文件夾中查找:

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; 
    } 
} 

回答

0

您需要設置範圍遞歸

爲此,您可以使用對象模型SPQuery.ViewAttributes

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

看起來你正在使用網絡服務GetListItems,所以你可以通過這個參數在QueryOptions

<QueryOptions> 
    <ViewAttributes Scope="Recursive" /> 
</QueryOptions> 
相關問題