0

I have big problem. I tried a lot of solution for this issue but not worked. I need help. Here is my code. I try to get items from picture library. It's an app for sharepoint online.

var context;
var web;
var user;
var list;
var slider_container = $(".bxslider");


var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));

currentcontext = new SP.ClientContext.get_current();
hostcontext = new SP.AppContextSite(currentcontext, hostUrl);
web = hostcontext.get_web();
list = web.get_lists().getByTitle("Slider");


var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<Query><OrderBy><FieldRef Name=\'ID\'/></OrderBy></Query>');
var collListItem = list.getItems(camlQuery);




currentcontext.load(list);
currentcontext.load(collListItem, 'Include(ID, FileRef)');
currentcontext.executeQueryAsync(onList, onFailList);


function getQueryStringParameter(paramToRetrieve) {
    var params =
    document.URL.split("?")[1].split("&");
    var strParams = "";
    for (var i = 0; i < params.length; i = i + 1) {
        var singleParam = params[i].split("=");
        if (singleParam[0] == paramToRetrieve)
            return singleParam[1];
    }
}


function onList() {

    var numerator = collListItem.getEnumerator();

    while (numerator.moveNext()) {

        var oListItem = numerator.get_current();

        var img = oListItem.get_item("FileRef"); //imgurl olacak
        var intname = oListItem.get_internalName();
        console.log(intname);

        var html = '<li><img src="' + img + '" /></li>';

        slider_container.append(html);


    }

}
  • More detail please. Where is the exception occurring? What exception is being thrown? – Bunzab Oct 4 '16 at 12:38
  • That's whole error : The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested. It thrown while page load. – Yasin Yörük Oct 4 '16 at 12:43
0

You need to include <View /> in the Caml:

camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name=\'ID\'/></OrderBy></Query></View>');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.