0
votes

I have a SharePoint 2010 list with the following site columns:

|  ID  |  Title  |  Status  | Assigned To |

I am trying to create a CAML query that will return all list items where Title=1234 AND Status!=In progress OR Completed

| Title | Status |
|  1234  |  In Progress  | = Don't return
|  1234  |  Completed  | = Don't Return
|  1234  |  Cancelled  | = Return
|  4598  |  Cancelled  | = Don't Return

I know there are tools like U2U CAML Query Builder, but I am unable to install software on my workstation.

Can anyone help me out?

Here is my query so far, but it doesn't work:

<Where>
<And>
  <Eq>
    <FieldRef Name='Title' />
    <Value Type='Text'>1234</Value>
  </Eq>
  <And>
  <Eq>
  <Neq>
        <FieldRef Name='Status' />
        <Value Type='Text'>In Progress</Value>
      </Neq>
  </Eq>
    <Or>
  <Eq>
  <Neq>
        <FieldRef Name='Status' />
        <Value Type='Text'>Completed</Value>
      </Neq>
  </Eq>
</Or>
  </And>
</And>

2

2 Answers

0
votes

When you want to use And or Or all you have to do is put your statements in a <And>/<Or> tag

<Where>
    <And>
        <Eq>
            <FieldRef Name="Title" />
            <Value Type="Text">1234</Value>
        </Eq>
        <Neq>
            <FieldRef Name="Status" />
            <Value Type="Text">In Progress</Value>
        </Neq>
    </And>
</Where>
0
votes

Fetch data using CAML Query where Author name = ‘Author2’ and Publisher Not equal to ‘Publisher1’ and stock is available Author2Publisher1Yes https://www.sharepointcafe.net/2015/06/caml-query-in-sharepoint.html