совместное использование JavaScript получить значение настраиваемого поля из библиотеки документов? - PullRequest
0 голосов
/ 16 октября 2018

Это вопрос общего ресурса.

1.Я загрузил несколько фотографий в библиотеку документов.

enter image description here

2. Используйте javascript для получения атрибутов изображений

$(document).ready(function() {
    ExecuteOrDelayUntilScriptLoaded(getImages, "sp.js"); 
}); 
function getImages() {
    var ctx = new SP.ClientContext.get_current();
    var oLibDocs = ctx.get_web().get_lists().getByTitle("Documents");
    var caml = SP.CamlQuery.createAllItemsQuery();
    caml.set_viewXml("<View Scope='RecursiveAll'><Query><Where><Neq><FieldRef Name='ContentType' /><Value Type='Text'>Folder</Value></Neq></Where></Query></View>");
    this.allDocumentsCol = oLibDocs.getItems(caml);
    ctx.load(this.allDocumentsCol, "Include(FileLeafRef, ServerUrl)");
    ctx.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed)); 
} 
function onQuerySucceeded(sender, args) {
    var slideshow = "";
    var ListEnumerator = this.allDocumentsCol.getEnumerator();
    while (ListEnumerator.moveNext()) {
        var currentItem = ListEnumerator.get_current();
        var currentItemServerUrl = currentItem.get_item('ServerUrl');
        console.log(currentItemServerUrl);
    } 
} 
function onQueryFailed(sender, args) {
    console.log("failed. Message:" + args.get_message()); 
}

3. Это работает очень хорошо, я могу получить все картинки url

4. Теперь я добавляю новый столбец TargetUrl в библиотеку документов.

TargetUrl

Одна строка текста

enter image description here

Вопрос: Основываясь на приведенном выше коде, как я могу получить значение TargetUrl одновременно.

Просто напомните, ниже 1 или 2 не сработает.

//1.
caml.set_viewXml("<View Scope='RecursiveAll'><ViewFields><FieldRef Name='TargetUrl'/></ViewFields><Query><Where><Neq><FieldRef Name='ContentType' /><Value Type='Text'>Folder</Value></Neq></Where></Query></View>");

//2.
ctx.load(this.allDocumentsCol, "Include(FileLeafRef, ServerUrl, TargetUrl)");
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...