【问题标题】:ViewAttributes Recursive Scope not working SharePoint 2013 CAML Query to fetch all files from document library recursivelyViewAttributes 递归范围不起作用 SharePoint 2013 CAML 查询以递归方式从文档库中获取所有文件
【发布时间】:2016-03-16 19:19:55
【问题描述】:

我有一个文档库 SP 2013,想从所有文件夹和子文件夹中获取所有文档。我不想要任何文件夹,但我确实想从每个文件夹中获取所有文件。

使用 SP 2010 U2U CAML Builder,我做了以下查询:

<query>
<QueryOptions>
        <ViewAttributes Scope="Recursive" />
    </QueryOptions> 
</query>

此查询可在 SP 2010 中正常使用,但不适用于 SP 2013

下面是从 SP 2013 库中获取数据的代码

CAMLQuery = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>\
  <soapenv:Body>\
    <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>\
      <listName>My Document Library</listName>\
<query>\
<QueryOptions>\
        <ViewAttributes Scope="Recursive" />\
    </QueryOptions> \
</query>\
    </GetListItems>\
  </soapenv:Body>\
</soapenv:Envelope>";

$.ajax({
    url: "https://<server>/teams/<siteName>/_vti_bin/lists.asmx",
    type: "POST",
    dataType: "xml",
    data: CAMLQuery,
    complete: getGrid,
    contentType: "text/xml; charset=\"utf-8\""
});

getGrid 是完成时的回调函数

请帮帮我。

【问题讨论】:

    标签: recursion sharepoint-2013 caml


    【解决方案1】:

    你必须在视图标签中给出范围,像这样:

    <View Scope="RecursiveAll">
        <Query>
            <Where>...</Where>
        </Query>
    </View>
    

    【讨论】:

      【解决方案2】:

      请使用 SP.ViewScope 属性更新视图范围 对于递归,值为 1。

      var view= list.get_views().getByTitle("YourView"); view.set_scope(2);

      https://msdn.microsoft.com/en-us/library/office/ee548053(v=office.14).aspx

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-07-28
        • 2018-10-07
        • 1970-01-01
        • 2019-06-26
        • 2020-09-20
        • 2013-05-15
        • 2019-02-20
        相关资源
        最近更新 更多