Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

CAML Query Logic Operator with two Logic Operators

$
0
0

I have written a CAML query that contains an Or operand which contains two And operands, ensuring that no single logic operand contains more than two conditions.

This CAML Query works great when placed in the aspx file. However, because the Sharepoint UI has no way to hand this query, whenever I make a change to the view using the SharePoint UI, The UI overrides my query.

Here is my Query:

<Where><Or><And><Geq><FieldRef Name="EventDate" /><Value Type="DateTime"><Today OffsetDays="-1" /></Value></Geq><Leq><FieldRef Name="EventDate" /><Value Type="DateTime"><Today OffsetDays="1" /></Value></Leq></And><And><Geq><FieldRef Name="EndDate" /><Value Type="DateTime"><Today OffsetDays="-1" /></Value></Geq><Leq><FieldRef Name="EventDate" /><Value Type="DateTime"><Today OffsetDays="1" /></Value></Leq></And></Or></Where>

The logic behind this query is:

If I have an event that starts or ends Yesterday, Today or Tomorrow, I want to select it.

If I have an event that stated in the past and ends in the future, I want to select it.

Is there a way I can avoid the SharePoint UI overwriting my query, or is there a better way to write the query?

Thank you!


Viewing all articles
Browse latest Browse all 7589

Trending Articles