Pages

Thursday, October 30, 2014

SPServices to get the ID of the last SharePoint list item (to identify the current item's ID in new form)

function findId(){

       var query = "";

       $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: “List Name”,
            CAMLQuery: query,
            CAMLRowLimit:1,
            completefunc: function (xData, Status) {
                               $(xData.responseXML).SPFilterNode("z:row").each(function() {
                                         var last_item_id = $(this).attr("ows_ID");
                                         return last_item_id;
                                 });
           }
      });//SPServices Ends

}//FindId Method Ends.


For additional information and updates on SPServices check Mark D Anderson's http://spservices.codeplex.com .

1 comment: