Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 2013 如何在文档集中搜索文件?_Sharepoint 2013_Caml - Fatal编程技术网

Sharepoint 2013 如何在文档集中搜索文件?

Sharepoint 2013 如何在文档集中搜索文件?,sharepoint-2013,caml,Sharepoint 2013,Caml,我正在尝试编写一个CAML查询,以按文件名在特定文档集中查找特定文件 这是我正在处理的查询: <Query> <Where> <Eq> <FieldRef Name='FileLeafRef' /> <Value Type='File'>TestFile.txt</Value>

我正在尝试编写一个CAML查询,以按文件名在特定文档集中查找特定文件

这是我正在处理的查询:

<Query> <Where> <Eq> <FieldRef Name='FileLeafRef' /> <Value Type='File'>TestFile.txt</Value> </Eq> </Where> </Query> <QueryOptions> <Folder>https://acme.com/sites/mysite/MyDocLib/MyDocSetName</Folder> </QueryOptions> TestFile.txt https://acme.com/sites/mysite/MyDocLib/MyDocSetName
由于在一个名为MyDocSetName的文档集中有一个名为TestFile.txt的文件,我希望得到一个结果,但什么都没有返回。我做错了什么?

基于的示例测试脚本


$(文档).ready(函数(){
var scriptbase=_spPageContextInfo.webServerRelativeUrl+“/_layouts/15/”;
$.getScript(scriptbase+“SP.Runtime.js”,函数(){
$.getScript(scriptbase+“SP.js”,函数(){
$.getScript(scriptbase+“SP.DocumentManagement.js”,createDocumentSet);
});
});
});
var文件;
函数createDocumentSet(){
//获取客户端上下文、web和库对象。
clientContext=new SP.clientContext.get_current();
oWeb=clientContext.get_web();
var oList=oWeb.get_lists().getByTitle(“DocSet”);
clientContext.load(oList);
//获取库的根文件夹
oLibraryFolder=oList.get_rootFolder();
var documentSetFolder=“/DocSet/test1”;
//使用CAML查询获取文档集文件
var camlQuery=SP.camlQuery.createAllItemsQuery();
camlQuery.set_viewXml(“test2.docx”);
camlQuery.set_folderServerRelativeUrl(documentSetFolder);
docSetFiles=oList.getItems(camlQuery);
//加载客户端上下文并执行批处理
load(docSetFiles,'Include(File)');
executeQueryAsync(QuerySuccess,QueryFailure);
}
函数QuerySuccess(){
//循环浏览文档集文件并获取显示名称
var docSetFilesEnumerator=docSetFiles.getEnumerator();
while(docSetFilesEnumerator.moveNext()){
var oDoc=docSetFilesEnumerator.get_current().get_file();
log(“文档名:+oDoc.get_Name());
}
}
函数QueryFailure(){
console.log('请求失败-'+args.get_message());
}

啊,这太完美了。这是套路的关键。真是一堆!
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script language="javascript" type="text/javascript">

        $(document).ready(function() {
            var scriptbase = _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/";
            $.getScript(scriptbase + "SP.Runtime.js", function() {
                $.getScript(scriptbase + "SP.js", function() {
                    $.getScript(scriptbase + "SP.DocumentManagement.js", createDocumentSet);
                });
            });
        });
        var docSetFiles;

        function createDocumentSet() {
            //Get the client context,web and library object.
            clientContext = new SP.ClientContext.get_current();
            oWeb = clientContext.get_web();
            var oList = oWeb.get_lists().getByTitle("DocSet");
            clientContext.load(oList);
            //Get the root folder of the library
            oLibraryFolder = oList.get_rootFolder();
            var documentSetFolder = "/DocSet/test1";
            //Get the document set files using CAML query
            var camlQuery = SP.CamlQuery.createAllItemsQuery();
            camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='Text'>test2.docx</Value></Eq></Where></Query></View>");
            camlQuery.set_folderServerRelativeUrl(documentSetFolder);
            docSetFiles = oList.getItems(camlQuery);
            //Load the client context and execute the batch
            clientContext.load(docSetFiles, 'Include(File)');
            clientContext.executeQueryAsync(QuerySuccess, QueryFailure);
        }

        function QuerySuccess() {
            //Loop through the document set files and get the display name
            var docSetFilesEnumerator = docSetFiles.getEnumerator();
            while (docSetFilesEnumerator.moveNext()) {
                var oDoc = docSetFilesEnumerator.get_current().get_file();
                console.log("Document Name : " + oDoc.get_name());
            }
        }

        function QueryFailure() {
            console.log('Request failed - ' + args.get_message());
        }
    </script>