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:
<Or> <In> <FieldRef Name='MyTaxonomyField' /> <Values> <Value Type='Integer'>1</Value> <Value Type='Integer'>2</Value> </Values> </In> <IsNull> <FieldRef Name='MyTaxonomyField'/> </IsNull> </Or>
<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