3

I am facing some problem with SharePoint 2013 CAML Query. I have a list and there is a look up column on it. There are some values on the lookup column.For example, I have Full Access and Limited Access values in look up column. Now I want to get all the ListItems whose look up column does not contains "Full Access".

I wrote this query:

<Query>
   <Where>
    <And>
      <Eq>
        <FieldRef Name="DocumentTypeCal" />
        <Value Type="Text">Databases</Value>
      </Eq>
      <Contains>
        <FieldRef Name="Sub_x0020_Categories" />
        <Value Type="Lookup">Limited Access</Value>
      </Contains>
    </And>
  </Where>
</Query>

I have search a bit on Google but I did not find any or any tag that could solve my problem.

1

Try this query

<Query>
   <Where>
    <And>
      <Eq>
        <FieldRef Name="DocumentTypeCal" />
        <Value Type="Text">Databases</Value>
      </Eq>
      <Neq>
        <FieldRef Name="Sub_x0020_Categories" />
        <Value Type="Lookup">Full Access</Value>
      </Neq>
    </And>
  </Where>
</Query>

You can also query on the ID of Full Access as below

<Query>
   <Where>
    <And>
      <Eq>
        <FieldRef Name="DocumentTypeCal" />
        <Value Type="Text">Databases</Value>
      </Eq>
      <Neq>
        <FieldRef Name="Sub_x0020_Categories" LookupId="TRUE"/>
        <Value Type="Text">1</Value>
      </Neq>
    </And>
  </Where>
</Query>
  • thanks for the reply. but you are comparing Sub_x0020_Categories value with Full Access. I wanted to exclude all the ListItem that contains Full Access. Its not string comparison , Its like String's Contains method. Hope you understand. – SM Farhad Ali Jan 20 '15 at 5:04

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.