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
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

  • Please mark the answer as correct if it solved your problem to close the question :) – Arsalan Adam Khatri Jun 1 '14 at 5:00
  • not yet unfortunately it's possible to modify my query – ezzaam Jun 1 '14 at 9:40
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

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.