How can i find what item failed executeQueryAsync add item method ?

this is my code :

var itemArray = [];
var siteUrl = "http://MySite/MM/cm";
var clientContext = SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('xy');

var itemCreateInfo = new SP.ListItemCreationInformation();
oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('FullName', "ali");
oListItem.set_item('CellPhone', "555-666");

itemArray[i] = oListItem;

clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);

function onQuerySucceeded() {
    console.log("item created in : ", oListItem.get_id());

function onQueryFailed(sender, args) {
    console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

I con not find out what item is duplicate in item creation that my query is failed ! if i can find it then i can update it and continue with others !

1 Answer 1


Pass the item you wanted to create, to the failed function with standard JavaScript bind
(supported in InternetExplorer since IE9)



clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed.bind(oListItem) );


function onQueryFailed(sender, args) {
    var oListItem = this;
    console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

Explained in detail in:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.