I'm trying to retrieve items from list using this Query:
query.Query =
@"<Where>
<And>
<And>
<Geq>
<FieldRef Name='Date' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(dateFrom) + @"</Value>
</Geq>
<Leq>
<FieldRef Name='Date' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(dateTo) + @"</Value>
</Leq>
</And>
<In>
<FieldRef Name='Employee' LookupId='TRUE' />
<Values>
<Value Type='int'>1</Value>
<Value Type='int'>3</Value>
</Values>
</In>
</And>
</Where>";
On runtime i get the following exception:
SPException: One or more field types are not installed properly. Go to the list settings page to delete these fields
on line List.GetItems(query)
.
If i modify SPQuery like this:
query.Query =
@"<Where>
<And>
<Geq>
<FieldRef Name='Date' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(dateFrom) + @"</Value>
</Geq>
<Leq>
<FieldRef Name='Date' /><Value Type='DateTime' IncludeTimeValue='TRUE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(dateTo) + @"</Value>
</Leq>
</And>
</Where>";
or this:
query.Query =
@"<Where>
<In>
<FieldRef Name='Employee' LookupId='TRUE' />
<Values>
<Value Type='int'>1</Value>
<Value Type='int'>3</Value>
</Values>
</In>
</Where>";
everything is working perfectly.
The problem was in reusing SPQuery
object, surprisingly. So I create a new SPQuery
and everything is OK.