0

I have this CAML query that wouldn't work if i change it to but works with HOWEVER. since our list no has 15k items using OR doesnt work. basically this remote event receiver gets list items with this CAML Query:

 var query = string.Format(
                @"<View>
                    <Query>
                       <Where>
                          <And>
                              <Eq>
                                <FieldRef Name='IsCurrentBooking' />
                                <Value Type='Boolean'>1</Value>
                              </Eq>
                              <And>
                                  <And>
                                     <Or>
                                        <Eq>
                                           <FieldRef Name='NG_BookingStatus' />
                                           <Value Type='Choice'>{2}</Value>
                                        </Eq>
                                        <Eq>
                                           <FieldRef Name='NG_BookingStatus' />
                                           <Value Type='Choice'>{3}</Value>
                                        </Eq>
                                     </Or>
                                     <And>
                                        <Lt>
                                            <FieldRef Name='NG_EventDate' />
                                            <Value IncludeTimeValue='TRUE' Type='DateTime' StorageTZ='TRUE'>{1}</Value>
                                        </Lt>
                                        <Gt>
                                            <FieldRef Name='NG_EndDate' />
                                            <Value IncludeTimeValue='TRUE' Type='DateTime' StorageTZ='TRUE'>{0}</Value>
                                        </Gt>
                                    </And>
                                  </And>
                                  <Eq>
                                    <FieldRef Name='NG_Venues' LookupId='TRUE' />
                                    <Value Type='LookupMulti'>{4}</Value>
                                  </Eq>
                              </And>
                           </And>
                       </Where>
                        <OrderBy>
                            <FieldRef Name='NG_EventDate' Ascending='True' />
                        </OrderBy>
                    </Query>
                </View>"
                , startDate, endDate, status_w1, status_w2, venueId);

this condition in particular:

<Or>
   <Eq>
     <FieldRef Name='NG_BookingStatus' />
      <Value Type='Choice'>{2}</Value>
    </Eq>
    <Eq>
       <FieldRef Name='NG_BookingStatus' />
       <Value Type='Choice'>{3}</Value>
     </Eq>
</Or>

I've read here never to use OR but i am not sure what to do because changing it to AND does not return any time for obvious reasons. but i cant seem to get how to workaround this.

0

The article you reference gives the only answer you're going to get:

Your only option here is to run multiple queries.

So do one query with AND:

<Eq>
    <FieldRef Name='NG_BookingStatus' />
    <Value Type='Choice'>{2}</Value>
</Eq>

and another query with AND:

<Eq>
    <FieldRef Name='NG_BookingStatus' />
    <Value Type='Choice'>{3}</Value>
</Eq>

and manually merge the results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.