Retrieving the id of an inserted item using sp services
I was working on a project the other day and needed to get the id of an inserted item into a SharePoint 2007 custom list. I was not even sure if it was possible and if there was any sample code out there. With faith and my good friend beside me, Google, I began my search. I searched everywhere and finally came to this helpful site http://www.bjw.co.nz/developer/sharepoint-2010/1173-returning-the-new-id-with-spservices-updatelistitems
Here’s how I used the code:
function getID(measureID,FY) { var newItemID = null; $().SPServices({ operation: "UpdateListItems", listName: "Results List", batchCmd: "New", async: false, valuepairs: [ ["Title", measureID], ["FiscalYear", FY] ], completefunc: function(xData, Status) { var newId = $(xData.responseXML).SPFilterNode("z:row").attr("ows_ID"); newItemID = newId; } }); return newItemID; }
Hopefully, this blog post can narrow the search on this topic. 🙂