Mavention Blog > Maart 2009

SPS2003: CAML query problem with Contains in combination with Calculated Column

I wanted to create a tailor made view of a list, using the first position in a calculated column to determine whether or not to place specific text in a cell. This calculated column A contains a status description of items in the list (1. Starting, 2. In Progress, ...).

In case an item is in phase 1 or 2, I wanted to show a specific text in the first cell. I used Frontpage 2003 to edit the page and I set the filter options using the standard dialog to A contains 1 Or A contains 2.

I succesfully tested the page in Frontpage, saved the page and found out that I got a nasty message:



All other pages kept working though. Just this page refused to serve right.

I checked the CAML code:

<dsp:Where xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp">
<dsp:Or>
<dsp:Contains>
<dsp:FieldRef Name="A"/>
<dsp:Value Type="xsd:string">1.</dsp:Value>
</dsp:Contains>
<dsp:Contains>
<dsp:FieldRef Name="A"/>
<dsp:Value Type="xsd:string">2.</dsp:Value>
</dsp:Contains>
</dsp:Or>
</dsp:Where>

And modified it to:
<dsp:Where xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp">
<dsp:Contains>
<dsp:FieldRef Name="A"/>
<dsp:Value Type="xsd:string">1.</dsp:Value>
</dsp:Contains>
</dsp:Where>
to see if the OR clause would be causing the problem. Unfortunately, still same error.

Now I tried:
<dsp:Where xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp">
<dsp:Eq>
<dsp:FieldRef Name="A"/>
<dsp:Value Type="xsd:string">1. Starting</dsp:Value>
</dsp:Eq>
</dsp:Where>
This one worked. Would it be the Contains clause?

I checked with some other field:
<dsp:Where xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp">
<dsp:Contains>
<dsp:FieldRef Name="ID"/>
<dsp:Value Type="xsd:string">56</dsp:Value>
</dsp:Contains>
</dsp:Where>
This one worked as well.

My conclusion is that you cannot use the Contains clause on a calculated column. Work around I used, was replacing Contains with Eq (Equals)

<dsp:Where xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp">
<dsp:Or>
<dsp:Eq>
<dsp:FieldRef Name="A"/>
<dsp:Value Type="xsd:string">1. Starting</dsp:Value>
</dsp:Eq>
<dsp:Eq>
<dsp:FieldRef Name="A"/>
<dsp:Value Type="xsd:string">2. In Progress</dsp:Value>
</dsp:Eq>
</dsp:Or>
</dsp:Where>
Posted: 8-3-2009 21:11:52 by Marcel van der Lem | with 0 comments
Filed under: CAML, column, Contains, SPS2003, Calculated


Commentaren
Blogbericht heeft op dit moment nog geen commentaren.
Laat commentaar achter



 Security code