"The property Query contains an invalid value." - I can't see it

1.5k views Asked by At
query.Query = @"<Where>
<And>
<BeginsWith>
<FieldRef Name='ContentTypeId'/>
<Value Type='Text'>[LONG GUID]</Value>
</BeginsWith>
<And>
<Geq>
<FieldRef Name='PublishingStartDate' />
<Value Type='DateTime'>2011-01-01T15:55:52Z</Value>
</Geq>
<Leq>
<FieldRef Name='PublishingStartDate' />
<Value Type='DateTime'>2011-01-01T15:55:52Z</Value>
</Leq>
</And>
</And>
</Where>
<OrderBy>
<FieldRef Name='PublishingStartDate' Ascending='FALSE' />
</OrderBy>";

The above query is attempting to bring back all items of a certain content type between two dates and order (descending) by the same date field.

EDIT: I should mention that this is an SPSiteDataQuery

2

There are 2 answers

1
Senthil S On

I do not see anything wrong in your CAML. One thing I noticed is the value of the PublishingStartDate filter values. Both Geq and Leq are having exactly the same date time value.

<Geq>
<FieldRef Name='PublishingStartDate' />
<Value Type='DateTime'>2011-01-01T15:55:52Z</Value>
</Geq>
<Leq>
<FieldRef Name='PublishingStartDate' />
<Value Type='DateTime'>2011-01-01T15:55:52Z</Value>
</Leq>

Are you sure that both filter should be using the same date time?

0
Tsvetelin Pavlov On

Maybe it's too late to answer this, but for further reference: the problem is that you can't have new line symbols in the query or view felds. I had the same problem - if you put all of CAML on one row, it will work.