0

I'm trying to retrieve a list of items where some conditions are applied but when I run my web page it returns all records. basically this query checks whether any record with these conditions exist or not, if exist function will validate and will not create a new item and vice versa

Here's what my CAML query looks like:

<Query>
   <Where>
      <And>
         <Eq><FieldRef Name='Name' LookupId='TRUE' /><Value Type='Integer'>28</Value></Eq>
         <And>
            <Neq><FieldRef Name='WorkflowStatus'/><Value Type='Text'>Rejected</Value></Neq> 
            <And>    
                <Neq><FieldRef Name='ID' /><Value Type='Number'>173</Value></Neq>              
                <And>
                    <Geq><FieldRef Name='HRLastDayOfLeave'/><Value Type='DateTime' IncludeTimeValue='FALSE'>2015-10-9</Value></Geq>
                    <Leq><FieldRef Name='HRFirstDayOfLeave'/><Value Type='DateTime' IncludeTimeValue='FALSE'>2015-10-8</Value></Leq>
                </And>
           </And>
       </And>
    </And>
  </Where>
</Query>
1

Try to put your query in View tag. It will retrieve filter data only.

I.e.

<View><Query>
      <Where>
        <And>
            <Eq><FieldRef Name='Name' LookupId='TRUE' /><Value Type='Integer'>28</Value></Eq>
            <And>
                <Neq><FieldRef Name='WorkflowStatus'/><Value Type='Text'>Rejected</Value></Neq> 
                <And>    
                    <Neq><FieldRef Name='ID' /><Value Type='Number'>173</Value></Neq>  
                    <And>
                        <Geq><FieldRef Name='HRLastDayOfLeave'/><Value Type='DateTime' IncludeTimeValue='FALSE'>2015-10-9</Value></Geq>
                        <Leq><FieldRef Name='HRFirstDayOfLeave'/><Value Type='DateTime' IncludeTimeValue='FALSE'>2015-10-8</Value></Leq>
                    </And>
                </And> 
            </And>
        </And>
    </Where>
 </Query></View>

Your Answer

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

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