I am trying to get the rating field from a SharePoint pages library in JavaScript, after using the get_item('AverageRating') it's returning null.
My function looks like the following:
var context = SP.ClientContext.get_current();
var targetList = context.get_web().get_lists().getByTitle('Pages');
var query = new SP.CamlQuery();
query.set_folderServerRelativeUrl("pages/subfolder");
query.set_viewXml('<View Scope=\"RecursiveAll\">\
<Query>\
<Where>\
<Neq>\
<FieldRef Name="ContentType" />\
<Value Type="Text">Folder</Value>\
</Neq>\
</Where>\
<OrderBy><FieldRef Name="Created" Ascending="FALSE"/></OrderBy></Query></View>');
var listItems = targetList.getItems(query);
var results = context.loadQuery(listItems);
context.executeQueryAsync(_onSucceed, _Fail);
function _onSucceed(){
var html="";
for(var i = 0; i <results.length; i++){
html+="<p>"+results[i].get_item("AverageRating")+"</p>";
}
$(divSelector).html(html);
}
function _Fail(){
alert("fail");
}
Is there something wrong with this approach?

0 commentaires:
Enregistrer un commentaire