Needed help to build caml Query with multiple <And>

3.2k Views Asked by At

I am getting a query from list view by view.Query i got the following

<QUERY><GroupBy Collapse="TRUE" GroupLimit="100"><FieldRef Name="AlertGrp" /></GroupBy>       <OrderBy><FieldRef Name="PriorityNoLink" Ascending="FALSE" /><FieldRef Name="match_time"   Ascending="FALSE" /></OrderBy><Where><And><And><And>
<Neq><FieldRef Name="Category" /><Value Type="Text">ACH Alert</Value></Neq>
<Neq><FieldRef Name="Category" /><Value Type="Text">Check Fraud</Value></Neq>
</And>
<IsNull><FieldRef Name="Close_x0020_Reason" /></IsNull></And>
<Eq><FieldRef Name="AlertType" /><Value Type="Text">Alert</Value></Eq>
</And>
</Where></QUERY>

I want to add one more condition something like

<Geq><FieldRef Name="Created" /><Value Type="DateTime"><Today OffsetDays="-5" />    </Value></Geq>

I added after AlertType

<Eq><FieldRef Name="AlertType" /><Value Type="Text">Alert</Value></Eq>
</And>

and start tag < And> added in the beginning along with "< And>< And>< And>"

But showing wrong result. Kindly help me where i can add the new condition.

regards jhanani

1

There are 1 best solutions below

4
On

All your filters will be AND?

Try This:

<Where>
  <And>
    <And>
      <And>
        <And>
          <Neq>
            <FieldRef Name="Category" />
            <Value Type="Text">ACH Alert</Value>
          </Neq>
          <Neq>
            <FieldRef Name="Category" />
            <Value Type="Text">Check Fraud</Value>
          </Neq>
        </And>
        <IsNull>
          <FieldRef Name="Close_x0020_Reason" />
        </IsNull>
      </And>
      <Geq>
        <FieldRef Name="Created" />
        <Value Type="DateTime"><Today OffsetDays="-5" />
        </Value>
      </Geq>
    </And>
    <Eq>
      <FieldRef Name="AlertType" />
      <Value Type="Text">Alert</Value>
    </Eq>
  </And>
</Where>