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