I am creating a new item using NewForm.aspx opened using SP showModalDialog. How can I get the ID of created item after form is saved?

I need to get the ID to do some processing.

  • 1
    See 1 & 2. – moe Jun 27 '17 at 5:37

I solved this using SPServices

var lastID = $().SPServices.SPGetLastItemId({
    listName:'List 1'

this will get last inserted item's id which was created by same user.

List 1 is list's name


You can try running a SP2013 REST api and

get top 1 item while they are sorted by Created date in descending order

once your model dialog saves data in the list. Please refer this:

 _api/web/Lists/GetByTitle('your_List_title')/items?$top=1&$select=ID&$orderby=Created desc
  • We can consider using CreatedBy id, so in case of multi user environment you will get the last inserted by same user – codemirror Jul 4 '17 at 11:28

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.