SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It seems my following query is failing and throwing "Cannot complete this action".However when I test this query in CAML Query builder it's working fine.

<Where>
    <And>
       <Or>
         <Eq><FieldRef Name='Participant' /><Value Type='User'>Test1</Value></Eq>
         <Eq><FieldRef Name='Participant' /><Value Type='User'>Test2</Value></Eq>
         <Eq><FieldRef Name='Participant' /><Value Type='User'>Test3</Value></Eq>
        </Or>
      <Eq><FieldRef Name='Department' /><Value Type='Text'>Positioning</Value></Eq>
     </And>
 </Where>
share|improve this question
up vote 1 down vote accepted

And and Or elements have exactly 2 children. Your Or statement needs to be rephrased as

<Or>
  <Eq><FieldRef Name='Participant' /><Value Type='User'>Test1</Value></Eq>
  <Or>
     <Eq><FieldRef Name='Participant' /><Value Type='User'>Test2</Value></Eq>
     <Eq><FieldRef Name='Participant' /><Value Type='User'>Test3</Value></Eq>
  </Or>
</Or>
share|improve this answer
    
@Igaud, Thanks.. I'm generating query dynamically and my <OR> condition can increase up to any limit.What's the best way to arrange ? – Rishi Apr 3 '13 at 16:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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