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

1 Answer 1

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 and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.