I am creating an item in JSOM, SharePoint Designer 2013 for SharePoint on premise, and the same code that works fine for SharePoint online clients is not working fine now it keeps returning ID -1 for the newly created item:

function SAVE(){
    var clientContext = new SP.ClientContext();
    var oList = clientContext.get_web().get_lists().getByTitle('LIST NAME');

    var itemCreateInfo = new SP.ListItemCreationInformation();
    oListItem = oList.addItem(itemCreateInfo);
    oListItem.set_item('Title', 'Title field');     

function onAddSucceeded(sender, args) {
    var newItemId = oListItem.get_id();  //get Id of newly create item
    alert('pass ' + newItemId);

function onAddFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
  • I could not reproduce your issue with your code. – Amos Sep 29 '20 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.