I need some assistance with a complex CAML query. I can get parts of it working but cannot get all of it working together. What I need in laymans terms is this:
Where Country = US
AND Status BEGINSWITH A OR Status BEGINSWITH B OR Status BEGINSWITH C
OR Status BEGINSWITH D OR Status BEGINSWITH E OR Status BEGINSWITH F
AND Relationship NOT EQUALS to N/A OR IsComplete EQUALS Yes OR IsApproved EQUALS Yes
I have the statement laid out like this:
<Where>
<And>
<Eq><FieldRef Name='ContractingCountry' /><Value Type='Text'>Canada</Value></Eq>
<Or>
<Or>
<Or>
<BeginsWith><FieldRef Name='Status' /><Value Type='Text'>A</Value></BeginsWith>
<BeginsWith><FieldRef Name='Status' /><Value Type='Text'>B</Value></BeginsWith>
</Or>
<Or>
<BeginsWith><FieldRef Name='Status' /><Value Type='Text'>C</Value></BeginsWith>
<BeginsWith><FieldRef Name='Status' /><Value Type='Text'>D</Value></BeginsWith>
</Or>
</Or>
<Or>
<BeginsWith><FieldRef Name='Status' /><Value Type='Text'>E</Value></BeginsWith>
<BeginsWith><FieldRef Name='Status' /><Value Type='Text'>F</Value></BeginsWith>
</Or>
</Or>
</And>
<And>
<Or>
<Neq><FieldRef Name='Relationship' /><Value Type='Text'>N/A</Value></Neq>
<Or>
<Eq><FieldRef Name='IsComplete' /><Value Type='Text'>Yes</Value></Eq>
<Eq><FieldRef Name='Approved' /><Value Type='Text'>Yes</Value></Eq>
</Or>
</Or>
</And>
</Where>
The Query runs but it seems to ignore the last part of the statement as it is pulling back things where the Relationship = N/A
.