Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How can I use the list.addItem with the list newform.aspx?

$
0
0

I want to use the code below to create the new list item along with the newform.aspx. How can I do it?

The reason is that I need the id of the newly created item.


    var clientContext = SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle(mylist);
    var itemCreateInfo = new SP.ListItemCreationInformation();
    var my_item = oList.addItem(itemCreateInfo);
    my_item.update();
    clientContext.load(my_item);
   clientContext.executeQueryAsync(Function.createDelegate(this, this.onTypeSucceeded), Function.createDelegate(this, this.onTypeFailed));
     
}
function onTypeSucceeded() 
{
  alert('Item created: ' + oListItem.get_id());

}

function onTypeFailed(sender, args) 
{
            alert("failed. Message:" + args.get_message());



faye fouladi


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>