vendredi 30 janvier 2015

Unable to get property 'get current' of undefined or null reference



function listAllCategories() {



var ctx = new SP.ClientContext(appWebUrl);
var appCtxSite = new SP.AppContextSite(ctx, hostWebUrl);

var web = appCtxSite.get_web(); //Get the Web

var list = web.get_lists().getByTitle("NewsList"); //Get the List

var query = new SP.CamlQuery(); //The Query object. This is used to query for data in the List

query.set_viewXml('<View><Query><OrderBy><FieldRef Name=\'Article Date\' Ascending=\'False\'/></OrderBy></Query>' + '<RowLimit>2</RowLimit></View>');


var items = list.getItems(query);

ctx.load(list); //Retrieves the properties of a client object from the server.
ctx.load(items);

var table = $("#tblcategories");
var innerHtml = "<table><p><h3></h3></p><tr><td></td><td><p></p><p></p></td></tr></table>";

//Execute the Query Asynchronously
ctx.executeQueryAsync(
Function.createDelegate(this, function () {
var itemInfo = '';
var enumerator = items.getEnumerator();
while (enumerator.moveNext()) {
var currentListItem = enumerator.get_current();
innerHtml += "<table><p><h3>" + currentListItem.get_item('Article Title') + "</h3></p><tr><td><img src='" + currentListItem.get_item('Article Thumbnail').$2_1 + "'/></td><td><p> " + currentListItem.get_item('Article Body') + "</p><p> Posted In: <a href = '" + currentListItem.get_item('Article Categories').$2_1 + "'>" + currentListItem.get_item('Article Categories').$3_1 + "</a></p></td></tr></table>";
}
table.html(innerHtml);
}),
Function.createDelegate(this, fail)
);


}








0 commentaires:

Enregistrer un commentaire