CAML queries: how to filter folders from result set?

后端 未结 8 1631
遇见更好的自我
遇见更好的自我 2021-02-12 11:38

I\'m using caml query to select all documents which were modified or added by user. Query runs recursively on all subsites of specified site collection.

Now problem is I

8条回答
  •  逝去的感伤
    2021-02-12 12:02

    According to the output from CAML Designer (created by Karine Bosch and Andy Van Steenbergen and distributed by the Belux Information Worker User Group) the correct CAML syntax is:

    
      
        
        0
      
    
    
      
    
    

    I tested this in PowerShell and got the expected result:

    $qry = new-object Microsoft.SharePoint.SPQuery
    $qry.Query = "0"
    
    $items = $lib.GetItems($qry)
    $items.Count
    

    You can replace the tag in the CAML with the SPQuery object property ViewAttributes if you prefer, ie $qry.ViewAttributes = “Scope=’RecursiveAll’".

    When testing this be sure to re-instantiate the SPQuery object each time as you cannot simple reassign the Query property. Once the query has been executed, any new value assigned to the Query property is ignored. So execute the entire PowerShell fragment.

提交回复
热议问题