Свойства списка получения Ecma SharePoint

Я пытаюсь прочитать список свойств с помощью SharePoint ECMA, но не удалось.

Любой может помочь - вот код - попробовал с методами get_fieldValues ​​и get_item, и оба вернули "undefined".

var key = "vti_level";
function getListProperty() {
    var clientContext = new SP.ClientContext();
    var listGuid = GetUrlKeyValue('List', window.location.href);
    this.props = clientContext.get_web().get_lists().getById(listGuid).get_rootFolder();
    clientContext.load(this.props);
    clientContext.executeQueryAsync(Function.createDelegate(this, getListPropertySuccess), Function.createDelegate(this, getListPropertyFailed));
}

function getListPropertySuccess() {
    var propKey1 = this.props.get_properties().get_fieldValues()[key];
    var propKey2 = this.props.get_properties().get_item(key);
}

function getListPropertyFailed() {
    alert('Request failed on getListProperty.');
}

1 ответ

Решение

Попробуй это:

    var key = "vti_level";

        function getListProperty() {
            var clientContext = new SP.ClientContext();
            var listGuid = _spPageContextInfo.pageListId;
            this.props = clientContext.get_web().get_lists().getById(listGuid).get_rootFolder().get_properties();
            clientContext.load(this.props);
            clientContext.executeQueryAsync(Function.createDelegate(this, getListPropertySuccess), Function.createDelegate(this, getListPropertyFailed));
    }
    function getListPropertySuccess() {
        var propKey1 = this.props.get_fieldValues()[key];
        var propKey2 = this.props.get_item(key);
    }
    function getListPropertyFailed() {
        alert('Request failed on getListProperty.');
    }
Другие вопросы по тегам