0

I have a Multiple Lookupfield on my List (list of document sets)

When I do this query it works and shows me the results on the screenshot:

<Query>
   <Where>
         <Eq>
            <FieldRef Name='ClientCode' />
            <Value Type='Text'>12345678</Value>
         </Eq>
   </Where>
</Query>
<ViewFields>
   <FieldRef Name='JobsSearchMulti' />
</ViewFields>
<QueryOptions />

enter image description here

Now I need to do a query with both client code and job code

like this:

<Query>
   <Where>
<And>
      <Eq>
         <FieldRef Name='ClientCode' />
         <Value Type='Text'>12345678</Value>
      </Eq>
      <Contains>            
         <FieldRef Name='JobsSearchMulti' />            
         <Value Type='JobCascadingLookupMultipleV2'>T005</Value>         
       </Contains>
</And>
   </Where>
</Query>
<ViewFields>
   <FieldRef Name='JobsSearchMulti' />
</ViewFields>
<QueryOptions />

or this:

<Query>
   <Where>
<And>
      <Eq>
         <FieldRef Name='ClientCode' />
         <Value Type='Text'>12345678</Value>
      </Eq>
      <Contains>

         <FieldRef Name='JobsSearchMulti' />            
         <Value Type='Text'>T005</Value>         
       </Contains>
</And>
   </Where>
</Query>
<ViewFields>
   <FieldRef Name='JobsSearchMulti' />
</ViewFields>
<QueryOptions />

It should return results but its not doing it.

1
  • 1
    if its a multi-lookup, shouldn't the Value Type be LookupMulti ? Can you check by modifying it as <Contains> <FieldRef Name='JobsSearchMulti' /> <Value Type='LookupMulti'>T005</Value> </Contains> Nov 9, 2017 at 14:29

1 Answer 1

1

You have the wrong type and it's been known that CONTAINS is very flaky much like some of the rest of the CAML query language (I'm looking at you recurring events). Using EQ here will probably be your best bet. Try this:

<Eq><FieldRef Name=\"JobsSearchMulti\" LookupId=\"TRUE\"/><Value Type=\"LookupMulti\">19448</Value></Eq>

https://naimmurati.wordpress.com/2013/12/03/multi-lookup-fields-in-caml-queries-eq-vs-contains/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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