2011-01-06 53 views
3

我正在使用jQuery和WSS 3.0 SOAP服務從列表中檢索和顯示數據。我想通過CreatedBy列過濾數據。這裏是我的CAML查詢:SharePoint - 在GetListItems上進行用戶查詢SOAP調用

<Query> 
<Where> 
    <And> 
     <Leq> 
      <FieldRef Name="Created" /> 
      <Value Type="DateTime" IncludeTimeValue="FALSE">2011-1-8</Value> 
     </Leq> 
     <Geq> 
      <FieldRef Name="Created" /> 
      <Value Type="DateTime" IncludeTimeValue="FALSE">2011-1-2</Value> 
     </Geq> 
     <Contains> 
      <FieldRef Name="CreatedBy" LookupId="TRUE" /> 
      <Value Type="User">Smith</Value> 
     </Contains> 
    </And> 
</Where> 

當我執行這個時,SharePoint返回以下錯誤:

0x80004005的 - 無法完成此動作。請再試一次。

刪除用戶查找可解析頒發者。我哪裏錯了?

回答

4

如果你想使用他們的顯示名稱,那麼你不能使用LookupId="TRUE"Type="User"。它應該是:

<Contains> 
    <FieldRef Name="CreatedBy" /> 
    <Value Type="Text">Smith</Value> 
</Contains> 

更多的例子見my answer here

編輯:

另外,我只注意到你的<And></And>節點包含三個子節點。每個人只能包含兩個,這意味着你需要這樣的東西:

<Where> 
    <And> 
    <And> 
     <Leq> 
     <FieldRef Name="Created" /> 
     <Value Type="DateTime" IncludeTimeValue="FALSE">2011-1-8</Value> 
     </Leq> 
     <Geq> 
     <FieldRef Name="Created" /> 
     <Value Type="DateTime" IncludeTimeValue="FALSE">2011-1-2</Value> 
     </Geq> 
    </And> 
    <Contains> 
     <FieldRef Name="CreatedBy" /> 
     <Value Type="Text">Smith</Value> 
    </Contains> 
    </And> 
</Where> 
+0

謝謝,我會給它一個鏡頭! – dxprog 2011-01-09 02:08:18