2

I have a CAML query where I want to check if a field's "status" is equal to "Ordered" or "Approved".

I've located the documentation for IN in CAML but it's not very specific.

I've tried two queries, both unsuccessfully:

<View><Query><Where><Eq><FieldRef Name=""Status""></FieldRef><Value Type=""Text"">Ordered</Value><Value Type=""Text"">Approved</Value></Eq></Where></Query></View>

And

<View><Query><Where><In><FieldRef Name = "Status"/><Values><Value Type = "Approved"/><Value Type = "Ordered"/></Values></In></Where></Query></View>

This query works, validating the data but it's only testing against one element:

<View><Query><Where><Eq><FieldRef Name=""Status""></FieldRef><Value Type=""Text"">Approved</Value></Eq></Where></Query></View>

How do I properly use IN in my statement?

1 Answer 1

3

First one is wrong, because you can have only one Value child in Eq element.

Second one is wrong, because you put your desired values in Type attribute. You've used correct syntax in first one: <Value Type='Text'>Ordered</Value>

So the correct query is:

<View><Query><Where><In><FieldRef Name="Status"/><Values><Value Type="Text">Ordered</Value><Value Type="Text">Approved</Value></Values></In></Where></Query></View>
1
  • Thanks, I appreciate the answer and especially the insight into why it was broken.
    – Michael A
    Commented Aug 25, 2015 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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