1

I want to create CAML Query for following scenario,

(Metadata Name ="Author1" AND Value="Nitin Jagtap") AND (Metadata Name ="Program" AND Value="MBA").

I have tried but not able to create CAML query for same. I have used CAML Designer for same but unable to get proper result.

     Following is the CAML Query which is generated by using CAML Designer but it is not giving results        
  <Where>
  <And>
     <And>
        <And>
           <Eq>
              <FieldRef Name='Metadata_x0020_Name' />
              <Value Type='Lookup'>Author 1</Value>
           </Eq>
           <Eq>
              <FieldRef Name='Value' />
              <Value Type='Text'>Nitin Jagtap</Value>
           </Eq>
        </And>
        <Eq>
           <FieldRef Name='Metadata_x0020_Name' />
           <Value Type='Lookup'>Program</Value>
        </Eq>
     </And>
     <Eq>
        <FieldRef Name='Value' />
        <Value Type='Text'>MBA</Value>
     </Eq>
  </And>

I have a list having name “Metadata Values” which contains two columns

  • Metadata Name (which is a Lookup Column from Metadata List)
  • Value (which is Single line of text column) The list “Metadata Values” contains multiple records for each Metadata Name having different- different values or same values.

How should I create proper CAML query, so it will gives proper results. Please guide me.

3
  • Is that really a valid scenario? You can not have f.e. Value equal both MBA and Nitin Jagtap. Should there be an OR between the parentesis instead? Commented Jul 29, 2016 at 12:13
  • And the structure looks wrong too, I'd go back to CAML Designer and try configuring this again Commented Jul 29, 2016 at 12:20
  • Thanks Robert,for your reply.This is a valid scenario.Okay I will try using OR Commented Jul 29, 2016 at 13:00

1 Answer 1

0

Your query for Managed metadata(Multivalues) Column should be:

<FieldRef Name='Metadata_x0020_Name' />
  <values>
      <Value Type='Lookup'>Author 1</Value>
      <Value Type='Lookup'>Program</Value>
  </values>

Your Answer

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

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