4

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 appreciated

  • 2
    Instead of In why you are not using Eq? – Amal Hashim May 30 '15 at 13:51
  • What type is your fields? Is it Lookups or Integer columns? – ECM4D May 30 '15 at 19:41
  • Columns are taxoniny fields and the query is built @ runtime and I don't know the number of values the user wnats to query – Gianluca Fares May 31 '15 at 14:16
  • Can you just use the internal name of column instead of using lookup like: <FieldRef Name='COLUMN1' /> – Nadeem Yousuf Jun 1 '15 at 8:51
  • Hi Yousuf, I really don't think the FieldRef is causing the issue I'm talking about. The issue is that if I use the In operator inside a boolean Or it doesn't work as expected :-( – Gianluca Fares Jun 1 '15 at 9:21
4

maybe a bug on FieldRef using ID or LookupId because of querying the list in this way

<Where>
<Or>
<In>
        <FieldRef Name="COLUMN1"/>
        <Values>
          <Value Type='Text'>VALUE1</Value>
          <Value Type='Text'>VALUE2</Value>
        </Values>
      </In>
<In>
        <FieldRef Name="COLUMN2"/>
        <Values>
          <Value Type='Text'>VALUE3</Value>
          <Value Type='Text'>VALUE4</Value>
        </Values>
      </In>
</Or>
</Where>

returns the expected results. Thanks to all.

  • This is what I had mentioned in the comment. – Nadeem Yousuf Jun 2 '15 at 7:09
  • Correct Nadeem but it souns really strange. Thanks a lot – Gianluca Fares Jun 2 '15 at 13:40
-1

in CAML <IN> operator should be used as follows

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

Let mw know if you have any questions.

  • 1
    @Gianluca wants to filter on different columns. – ECM4D May 30 '15 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.