SPSiteDataQuery with <in> operator

410 Views Asked by At

First of all... the query works. With SPQuery it does. The query yields exactly one result (as expected!).

However as soon as I use SPSiteDataQuery (and I need to) it yields two results. I realized if I don't use but instead (works in cases where there is only ONE value (such as in the example below) it works and only returns one result. I am using the operator as suggested by this Microsoft article on querying taxonomy fields with CAML: http://msdn.microsoft.com/en-us/library/ff625182(v=office.14).aspx

If two records are returned the first contains the note field (as desired) and the second one doesn't. All other columns are identical. So I went forth and omitted that note field from the viewfields selection - ét voilà: 1 result (unfortunately I really need that note field's content!).

<Where>
<And>
  <Eq>
    <FieldRef ID='c042a256-787d-4a6f-8a8a-cf6ab767f12d' /> <!-- content type name -->
    <Value Type='Text'>Standard Teaser</Value>
  </Eq>
  <And>
    <And>
      <Or>
        <Gt>
          <FieldRef ID='51d39414-03dc-4bd0-b777-d3e20cb350f7' /> <!-- publishing exp -->
          <Value Type='DateTime'>
            <Today/>
          </Value>
        </Gt>
        <IsNull>
          <FieldRef ID='51d39414-03dc-4bd0-b777-d3e20cb350f7' />
        </IsNull>
      </Or>
      <Or>
        <Leq>
          <FieldRef ID='a990e64f-faa3-49c1-aafa-885fda79de62' /> <!-- publishing start -->
          <Value Type='DateTime'>
            <Today />
          </Value>
        </Leq>
        <IsNull>
          <FieldRef ID='a990e64f-faa3-49c1-aafa-885fda79de62' />
        </IsNull>
      </Or>
    </And>
    <In>
      <!-- taxonomy field -->
      <FieldRef ID='CAFEF21A-D977-44F8-96E4-6F6DA6F90A59' LookupId='TRUE' />
      <Values>
        <Value Type='Integer'>2</Value>
      </Values>
    </In>
  </And>
</And>
</Where>

enter image description here

List Settings -> Columns

0

There are 0 best solutions below