I'm working on an application that uses a CAML query to return certain documents based on a number of search and filter parameters. I need some assistance with a query that uses both AND and OR conditions.
The simplified version of the query I need to run is:
WHERE Created >= '2018-10-01'
AND Created <= '2018-10-24'
AND (File_Type == 'docx' || File_Type == 'xlsx' || File_Type == 'pptx')
AND (Title CONTAINS 'weekly' || Description CONTAINS 'weekly')
And the CAML Query I have created is:
<Where>
<And>
<Geq>
<FieldRef Name="Created" /><Value Type="DateTime">2018-10-01 00:00:00</Value>
</Geq>
<And>
<Leq>
<FieldRef Name="Created" /><Value Type="DateTime">2018-10-24 00:00:00</Value>
</Leq>
<Or>
<Eq>
<FieldRef Name="File_x0020_Type" /><Value Type="Text">docx</Value>
</Eq>
<Or>
<Eq>
<FieldRef Name="File_x0020_Type" /><Value Type="Text">xlsx</Value>
</Eq>
<Or>
<Eq>
<FieldRef Name="File_x0020_Type" /><Value Type="Text">pptx</Value>
</Eq>
<Or>
<Contains>
<FieldRef Name="FileLeafRef" /><Value Type="Text">weekly</Value>
</Contains>
<Contains>
<FieldRef Name="Description0" /><Value Type="Text">weekly</Value>
</Contains>
</Or>
</Or>
</Or>
</Or>
</And>
</And>
</Where>
When I run the query I get all results where either of the Title/Description or File_Type parameters are met.
My question is how do I rearrange the CAML query to incorporate an AND condition for both Title/Description and File_Type?