I'm writing a CAML query for SharePoint. The list contains a term set field. I want to get all list items having specific terms, plus items where no term is set. My query contains this:

        <FieldRef Name='MyTaxonomyField' /> 
            <Value Type='Integer'>1</Value> 
            <Value Type='Integer'>2</Value> 
        <FieldRef Name='MyTaxonomyField'/>

The <In> clause gets all items with specific terms. <IsNull> gets all items without any terms. Individually both of these work. Put together like this they do not: Only the items with defined terms are returned (i.e. the <In> clause runs)

The order does not matter. Changing <IsNull> to something else gives similar results. <In> appears to override everything else (runs first?). Is this a knowns problem? Is there any solution except for exchanging <In> for a bunch of <Or> clauses?

  • 2
    I recognize this behavior. Sadly the only workaround I have is replacing with nested OR-s – Robert Lindgren Oct 4 '15 at 8:32
  • Is it perhaps possible to use <In> to select null values too? – rlv-dan Oct 5 '15 at 5:41
  • Not quite sure how one could do that? – Robert Lindgren Oct 5 '15 at 5:58

Your Answer

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

Browse other questions tagged or ask your own question.