0

I made CAML query to filter items in an SPList view but I want to apply this query only on the root folder of SPList, not the subfolders, because I copied items from the root folder to subfolder. When I want to open a subfolder I have to see the items there. Because I have items to hide them from the main view and I copied them to subfolders

<Query>
  <Where>
    <Or>
      <And>
        <Or>
           <Eq>
              <FieldRef Name='LinkFilename' />
              <Value Type='Computed'>Dossiers envoyés</Value>
           </Eq>
           <Eq>
              <FieldRef Name='LinkFilename' />
              <Value Type='Computed'>Dossiers à suivre</Value>
           </Eq>
        </Or>
        <Or>
           <Eq>
              <FieldRef Name='Editor' />
              <Value Type='User'>system</Value>
           </Eq>
           <Eq>
              <FieldRef Name='Editor' />
              <Value Type='User'>redacteur</Value>
           </Eq>
        </Or>
     </And>
     <Eq>
        <FieldRef Name='Envoy_x00e9__x0020_vers_x0020_directeur' />
        <Value Type='Boolean'>0</Value>
     </Eq>
   </Or>
  </Where>
</Query>


 // this is the filter that hide these items from the main view.
  then i moved them to the Dossiers envoyés subfolder when their value change from 0 
   to 1

    <Eq>
        <FieldRef Name='Envoy_x00e9__x0020_vers_x0020_directeur' />
        <Value Type='Boolean'>0</Value>
     </Eq>

 //my list root folder contains the followinf tree
 + dossiers envoyes
     - item 2
     - item 1
       ...
 + dossiers archive
    - item 1
    - item 2
     ...
 - item 1
 - item 2
Markus
  • 357
  • 6
  • 20
ezzaam
  • 159
  • 1
  • 3
  • 24

2 Answers2

1

If you want items in a specific folder (root folder in your case), you can use FileDirRef column and filter based on it..

<Eq>
   <FieldRef Name="FileDirRef" /> 
   <Value Type="Text">/folderPath</Value>
</Eq>

Have a look at:

Get Items Under Folder CAML

Arsalan Adam Khatri
  • 14,531
  • 3
  • 36
  • 59
0

at the end of my query before where i added

 <Or>
    <Contains>
      <FieldRef Name="FileDirRef" /> 
      <Value Type="Text">/folderPath</Value>
   </Contains>
<Or>

it does work

ezzaam
  • 159
  • 1
  • 3
  • 24