使用jsom从sharepoint文档库获取文档版本号

时间:2018-09-28 07:14:29

标签: sharepoint sharepoint-2010 csom sharepoint-jsom

嗨,在控制台日志中,我试图获取文档版本。我得到一些数字,但这是不正确的。谁能帮我这个忙。谢谢。

<script type="text/javascript"> SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() {}); SP.SOD.executeOrDelayUntilScriptLoaded(getLibraries, "sp.js"); function getLibraries() {
    var ctx = new SP.ClientContext.get_current();
    var oLibDocs = ctx.get_web().get_lists().getByTitle("Site Collection Documents");
    // var caml = SP.CamlQuery.createAllItemsQuery();
    caml = new SP.CamlQuery();
    caml.set_folderServerRelativeUrl("Lists/Site Collection Documents/PPEteam/")
    caml.set_viewXml("<View Scope='RecursiveAll'>
        <Query></Query>
    </View>");
    this.allDocumentsCol = oLibDocs.getItems(caml);
    ctx.load(this.allDocumentsCol, "Include(FileLeafRef, ServerUrl,ContentType,_UIVersionString,Title)");
    ctx.executeQueryAsync(Function.createDelegate(this, this.onSucceededCallback), Function.createDelegate(this, this.onFailedCallback));
    }
    function onSucceededCallback(sender, args) {
    debugger;
    var libList = "";
    var myArray = new Array()
    var foldername = "";
    var documentname = "";
    var ListEnumerator = this.allDocumentsCol.getEnumerator();
    while (ListEnumerator.moveNext()) {
    var currentItem = ListEnumerator.get_current();
    var ct = currentItem.get_contentType();
    var ver = currentItem.get_objectVersion()

    documentname = currentItem.get_item('ServerUrl').split('/')[currentItem.get_item('ServerUrl').split('/').length
- 1]
    console.log(documentname + " " + '^' + " " + currentItem.get_item('ServerUrl') + " " + '^' + " " + ver)       var currentItem = ListEnumerator.get_current();
    var currentItemURL = _spPageContextInfo.webServerRelativeUrl + currentItem.get_item('ServerUrl');
    libList += currentItem.get_item('FileLeafRef') + ' : ' + currentItemURL + '\n';
    }
    alert(libList);
    }

    function onFailedCallback(sender, args) {
    alert("failed. Message:" + args.get_message());
    } 

0 个答案:

没有答案