I'm currently using JSOM to insert new items to list.
var clientContext = new SP.ClientContext();
var oWeb = clientContext.get_web();
var oList = oWeb.get_lists().getByTitle("request");
var camlQuery = new SP.CamlQuery();
var oListItemCreationInformation = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(oListItemCreationInformation);
oListItem.set_item('formType', ftype);
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(onsuccess(), onfailed);
}
function onsuccess() {
alert("Success");
console.log( oListItem.get_id());
}
As I expected it will return the new item ID, but it only return -1.
What can I do to get the correct ID in order to help adding upload file to list function to my page?