How can I get the ID of a list item that I just inserted in a list using the SP C# client library?

  • After adding the Item, get the list items and sort it with creation date and get the first time. – Vishwas Goswami Sep 24 '15 at 11:23
  • Maybe you find your answer here: sharepoint.stackexchange.com/questions/96493/… – Patrick Sep 24 '15 at 11:31
  • I see that using JSOM I can use the callback function to grab the ID of the recently inserted but I'm not seeing how to do that using C# – Andre Morata Sep 24 '15 at 20:48

You can refer below sample:

ClientContext context = new ClientContext("http://SiteUrl"); 
List listObj = context.Web.Lists.GetByTitle("ListName"); 
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); 
ListItem newItem = listObj.AddItem(itemCreateInfo); 
newItem["Title"] = "My New Item!"; 
context.Load(newItem);//Load the new item
Console.WriteLine("ID of new item:{0}", newItem.Id);//Get ID 
  • It works! Thanks. – ZooZ May 29 at 11:01

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.