I'm using jQuery and the WSS 3.0 SOAP service to retrieve and display data from a list. I'm wanting to filter the data by the CreatedBy column. Here's my CAML query:
<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>
When I execute this, SharePoint returns the following error:
0x80004005 - Cannot complete this action. Please try again.
Removing the user lookup resolves the issuer. Where am I going wrong?
If you want to use their display name, then you cannot use LookupId="TRUE"
or a Type="User"
. It should be:
<Contains>
<FieldRef Name="CreatedBy" />
<Value Type="Text">Smith</Value>
</Contains>
See my answer here for more examples.
Edit:
Also, I just noticed your <And></And>
node contains three sub-nodes. Each one can only contain two, which means you need something like this:
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.