我有以下的代碼,這是從MSDN的網站修改後的版本,測試獲得該字段「用戶名」中指定的值相匹配的所有列表項:的Sharepoint GetListItems函數返回不匹配的項目
Dim xmlDoc = New System.Xml.XmlDocument()
Dim ndQuery As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "")
Dim ndViewFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "")
ndQuery.InnerXml = <Query>
<Where>
<Eq>
<FieldRef Name="UserID"/>
<Value Type="Text">Foo.Bar</Value>
</Eq>
</Where>
</Query>
ndViewFields.InnerXml = <ViewFields>
<FieldRef Name="Title"/>
<FieldRef Name="FirstName"/>
<FieldRef Name="Company"/>
<FieldRef Name="WorkPhone"/>
<FieldRef Name="HomePhone"/>
<FieldRef Name="Email"/>
<FieldRef Name="UserID"/>
</ViewFields>
我在與可選的用戶名=「John.Doe」列表中的一個項目,我叫GetListItems如下:
''Gets any user from the Sharepoint New Hires list that matches the UserID variable and print to console
Dim ndListItems As XmlNode =
sharepointList.GetListItems("New Hires", Nothing, ndQuery, ndViewFields, Nothing, Nothing, Nothing)
Console.WriteLine(ndListItems.OuterXml)
我預計不會得到任何結果回來,作爲用戶名的值做不匹配,但事實證明,我確實找回了列表項,這不是wha我想要發生。我不確定發生了什麼事。查詢結構是否正確?有沒有一些參數,我不知道必須包含在GetListItems函數?這是我在函數運行後得到的結果。
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<rs:data ItemCount="1">
<z:row ows_ContentTypeId="0x01060051A3C5B94E00A446B900C3759422E391" ows_Title="Doe" ows_FirstName="John" ows_Email="[email protected]" ows_Company="MyCompany" ows_WorkPhone="987-123-4567" ows_HomePhone="987-123-4567" ows_UserID="John.Doe" ows_ID="6" ows_ContentType="Contact" ows_Modified="2010-08-13 12:58:14" ows_Created="2010-08-13 12:58:14" ows_Author="23;#John Doe" ows_Editor="23;#John Doe" ows_owshiddenversion="1" ows_WorkflowVersion="1" ows__UIVersion="512" ows__UIVersionString="1.0" ows_Attachments="0" ows__ModerationStatus="0" ows_LinkTitleNoMenu="Doe" ows_LinkTitle="Doe" ows_SelectTitle="6" ows_Order="600.000000000000" ows_GUID="{750F74FC-1CA3-40A2-8237-CD04E0390722}" ows_FileRef="6;#Lists/NewHires/6_.000" ows_FileDirRef="6;#Lists/NewHires" ows_Last_x0020_Modified="6;#2010-08-13 12:58:14" ows_Created_x0020_Date="6;#2010-08-13 12:58:14" ows_FSObjType="6;#0" ows_PermMask="0x7fffffffffffffff" ows_FileLeafRef="6;#6_.000" ows_UniqueId="6;#{778A7804-ABAA-49DC-9061-DE050DE5F032}" ows_ProgId="6;#" ows_ScopeId="6;#{C084EB37-9260-47CD-A231-AC23477D4856}" ows__EditMenuTableStart="6_.000" ows__EditMenuTableEnd="6" ows_LinkFilenameNoMenu="6_.000" ows_LinkFilename="6_.000" ows_ServerUrl="/Lists/NewHires/6_.000" ows_EncodedAbsUrl="http://sbatsharepoint2/Lists/NewHires/6_.000" ows_BaseName="6_" ows_MetaInfo="6;#" ows__Level="1" ows__IsCurrentVersion="1" />
</rs:data>
</listitems>
UPDATE:
仍然沒有任何運氣,我有大約在我燒毛引號替換查詢字段類型的雙引號,但沒有做任何事情。我也嘗試用它的GUID替換列表名稱,再次沒有。我已經三重檢查了所有的函數調用,有參數和變量。仍然不確定問題是什麼。
UPDATE2:
試圖與另一場測試查詢,如下所示:
ndQuery.InnerXml = <Query>
<Where>
<Eq>
<FieldRef Name="Title"/>
<Value Type="Text">Mike</Value>
</Eq>
</Where>
</Query>
當然,還有與標題=「邁克」列表中沒有的項目,但該功能仍返回所有這幾項。
嗨Floyed,剛剛嘗試過,並沒有工作,我仍然得到一個項目,當我不應該。 – kingrichard2005 2010-08-16 17:27:17