I am implementing a caml query on a SharePoint list! I have 5 conditions and I place every 2 condition in one tag. but It is still get this exception: "can not complete this action. please try again!"
<And>
<Eq>
<FieldRef Name='fieldName1' />
<Value Type='Text' >value1</Value>
</Eq>
<And>
<Contains>
<FieldRef Name='fieldName2' />
<Value Type='Text' >value2</Value>
</Contains>
<Contains>
<FieldRef Name='fieldName3' />
<Value Type='Text' >value3</Value>
</Contains>
</And>
<And>
<Eq>
<FieldRef Name='fieldName4' />
<Value Type='DateTime' IncludeTimeValue='false'>2019-06-22</Value>
</Eq>
<Eq>
<FieldRef Name='fieldName5' />
<Value Type='DateTime' IncludeTimeValue='false'>2019-05-06</Value>
</Eq>
</And>
</And>
what is wrong with my query?
For comparisons involving multiple fields, it's more like bottom up approach, you start comparing 2 fields, then the result with 3rd field then the result with 4th field and so on. So, your query should be like:
<And>
<Eq>
<FieldRef Name='fieldName1' />
<Value Type='Text'>value1</Value>
</Eq>
<And>
<Contains>
<FieldRef Name='fieldName2' />
<Value Type='Text'>value2</Value>
</Contains>
<And>
<Contains>
<FieldRef Name='fieldName3' />
<Value Type='Note'>value3</Value>
</Contains>
<And>
<Eq>
<FieldRef Name='fieldName4' />
<Value Type='Text'>value4</Value>
</Eq>
<Eq>
<FieldRef Name='fieldName5' />
<Value Type='Text'>value5</Value>
</Eq>
</And>
</And>
</And>
</And>