The current script creates a table showing all Items from the list.

What I want to achieve is to: Limit the items to ONLY show latest top 10 IDs in the table.

e.g. If I have a list of 21 Items, it should display ID number 11 to 21 (Latest Top 10), sorted by ascending order.

<SCRIPT type=text/javascript> get() ;function get() { var method = "GetListItems";                
var webURL =  $().SPServices.SPGetCurrentSite() ;                    
var list = "Core Libraries";                     
var fieldsToRead = "<ViewFields>"+"<FieldRef Name='Name' />" +"</ViewFields>";
var query = "<Query><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query>";                  

({ operation: method, async: false, webURL: webURL, listName: list,
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLQuery: query, completefunc: function (xData, Status)
{ $(xData.responseXML).SPFilterNode("z:row").each(function()
{ var title = $(this).attr("ows_Title");
var update  =  $(this).attr("ows_Update");
var date  =  $(this).attr("ows_Date");

$("#myDataTable").append("<tr align='middle'>" +
"<td align='left'>"+date+"</td>" + "<td align='left'>"+update+"</td>" + "</tr>");

}); } }); };

1 Answer 1


use CamlRowLimit to get the top 10 results:

CAMLQuery: query,
CAMLRowLimit: 10,

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.