AnsweredAssumed Answered

CAML Query for 2 Values of a Multi-Select Field

Question asked by andreapasutti on Aug 7, 2017
Latest reply on Aug 7, 2017 by andreapasutti

Hi.

 

I have a CAML query where I want to look at an approver list and find the ID based on a set of criteria. The query looks at the NextNumber being greater than the current number, it looks for a match on the specific BizUnit and Area OR for a BizUnit or Area of "ALL". Both BizUnit and Area are multi-select lookup columns. Finally, and this is where my query errors, it looks for either the specific RequestType OR the RequestType of "ALL". The difference is that the RequestType is a multi-select choice column.

 

 

I have bolded and colored the part of the query that is failing. From what I have read, I don't want to use "Contains" and that it should work with "Includes".

 

<Query>

  <Lists>

    <List ID="{INTERNAL LIST ID}" />

  </Lists>

  <ViewFields>

    <FieldRef Name="ID" />

  </ViewFields>

  <Where>

    <And>

      <And>

        <And>

          <And>

            <Or>

              <Eq>

               <FieldRef Name="BizUnit"  />

                <Value Type="Lookup">ALL</Value>

              </Eq>

              <Eq>

                <FieldRef Name="BizUnit"  />

              <Value Type="Lookup">{ItemProperty:BizUnit}</Value>

              </Eq>

            </Or>

            <Or>

              <Eq>

                <FieldRef Name="Area"  />

                <Value Type="Lookup">ALL</Value>

              </Eq>

             <Eq>

                <FieldRef Name="Area"  />

                <Value Type="Lookup">{ItemProperty:Area}</Value>

              </Eq>

            </Or>

          </And>

            <Or>

          <In>

            <FieldRef Name="RequestType"  />

            <Values>

            <Value Type="MultiChoice">ALL</Value>

              <Value Type="MultiChoice">{WorkflowVariable:RequestType_text}</Value>

            </Values>

          </In>

            </Or>

            </And>

            <Gt>

              <FieldRef Name="NextNumber"  />

              <Value Type="Number">{WorkflowVariable:NextNumber_text}</Value>

            </Gt>

          </And>

          <Eq>

            <FieldRef Name="Active"  />

            <Value Type="Choice">Active</Value>

          </Eq>

        </And>

      </Where>

      <OrderBy>

        <FieldRef Name="NextNumber" Ascending="true" />

      </OrderBy>

    </Query>

Why doesn't this work? Any help would be appreciated.

Outcomes