Having some trouble with a very basic use of the JSOM controls for adding list items.
My code:
function submitClick(who, where, when, description, name, number) {
//alert(who + where + when + description + name + number);
var context = SP.ClientContext.get_current();
var list = context.get_web().get_lists().getByTitle('*my list name*');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = list.addItem(itemCreateInfo);
oListItem.set_item('Who', who);
oListItem.set_item('Where', where);
oListItem.set_item('When', when);
oListItem.set_item('Description', description);
oListItem.set_item('Name', name);
oListItem.set_item('Contact', number);
oListItem.set_item('CreateDate', Date.now());
oListItem.set_item('Title', Date.now().toString()); //column is hidden but required
oListItem.update();
context.load(oListItem);
context.executeQueryAsync(onCreateListItemSuccess, onCreateListItemFailed);
function onCreateListItemSuccess() {
alert('yay');
}
function onCreateListItemFailed(sender, args) {
alert('failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
}
As you can see, it's just about as basic as it gets- Problem is, the ProcessQuery call always returns this:
{
"SchemaVersion":"15.0.0.0","LibraryVersion":"16.0.21010.12006","ErrorInfo":{
"ErrorMessage":"Unknown Error","ErrorValue":null,"TraceCorrelationId":"71d0ad9f-b05d-b000-95bc-b4c0e452fdc8","ErrorCode":-1,"ErrorTypeName":"Microsoft.SharePoint.Client.UnknownError"
}
That's right- "Unknown Error" and no ErrorValue. What's going on here?
Who
&When
columns? what values you are passing to these columns?