CAML Query IN Operator

Hi all,
I have a sharepoint list with managed metadata column and I have to find items matching values from columns.
If I filter the list for a column, let's say COLUMN1

    <In>
            <FieldRef LookupId='TRUE' ID='919cad04-5872-42a5-8c79-93e38e5e5b96' />
            <Values>
              <Value Type='Integer'>65</Value>
            </Values>
          </In>
It returns the record RECORD1.
Now i filter the list for a second column, let's say COLUMNB,

    <In>
            <FieldRef LookupId='TRUE' ID='5a6a5ee4-d125-4c99-9109-f943d8da7af0' />
            <Values>
              <Value Type='Integer'>68</Value>
            </Values>
          </In>

It returns record RECORD2.
The issue is that if I run the query

    <Or>
            <In>
              <FieldRef LookupId='TRUE' ID='5a6a5ee4-d125-4c99-9109-f943d8da7af0' />
              <Values>
                <Value Type='Integer'>68</Value>
              </Values>
            </In>
            <In>
              <FieldRef LookupId='TRUE' ID='919cad04-5872-42a5-8c79-93e38e5e5b96' />
              <Values>
                <Value Type='Integer'>65</Value>
              </Values>
            </In>
          </Or>
No record is returned. I was expecting both record RECORD1 and RECORD2.
BTW SharePoint version is 2010.

Any help is appre

May 30th, 2015 9:43am

Hi,

I think you should use something like this : 

<Query>
    <Where>
        <In>
            <FieldRef LookupId="True" Name="TaxKeyword" />
            <Values>
                <Value Type="Integer">WSS ID OF KEYWORD</Value>
                <Value Type="Integer">WSS ID OF KEYWORD</Value>
            </Values>
        </In>
    </Where>
</Query>

Source : http://www.spdeveloper.co.in/articles/pages/querying-managed-metadata-fields-in-sharepoint2010.aspx

Regards

Samuel Levesque | http://sharepointerie.com | Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

Free Windows Admin Tool Kit Click here and download it now
May 30th, 2015 2:38pm

Hi

here is example for the same.

<Where>   <In>   <FieldRef Name='Designation' />   <Values>   <Value Type='Text'>Engineer</Value>   <Value Type='Text'>Architect</Value>   </Values>   </In>   </Where>

https://rmanimaran.wordpress.com/2011/03/11/new-in-sharepoint-2010-caml-query/

June 1st, 2015 3:06am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics