I tell you that I have been fighting with this bug a few days ago. He is winning ... On the EditForm I have a grid that points to another sherpoint list. I can add listitems to that other list or edit those already loaded. When saving the EditForm via JSOM, I save the changes in the item corresponding to the form and also in all the list items in the grid. According to the type of field, it is how you set the value. I use set_item (internalName, value) and then the update. To set the values I go through an array of key value objects, the key being the internal name. I capture the error with a try catch and it is given in the set_item, then I leave what it prints in the console.
Maximum call stack size exceeded RangeError: Maximum call stack size exceeded
at Function.Object$getType [as getType] (ScriptResource.axd?...)
at Object.Sys$_isInstanceOfType [as _isInstanceOfType] (ScriptResource.axd?...)
at Function$_validateParameterType [as _validateParameterType] (ScriptResource.axd?...)
at Function$_validateParameter [as _validateParameter] (ScriptResource.axd?...)
at Function$_validateParams [as _validateParams] (ScriptResource.axd?...)
at Function.Type$inheritsFrom [as inheritsFrom] (ScriptResource.axd?...)
at Object.Sys$_isInstanceOfType [as _isInstanceOfType] (ScriptResource.axd?...)
at Function$_validateParameterType [as _validateParameterType] (ScriptResource.axd.....)
at Function$_validateParameter [as _validateParameter] (ScriptResource.axd?....)
at Function$_validateParams [as _validateParams] (ScriptResource.axd?...)
It is not always given to me when I set the same type of field, so I think it should not be, apart from the list item of the EditForm I do it in the same way and the bug does not jump.
Thank you very much for your time, regards.
UPDATE:
Here is the code
function updateItemProperties(itemId, obj) {
var auxDef = $.Deferred();
var list = ListItems.getListByURLSynchronous(ctx, siteUrl, obj.list);
var item = list.getItemById(parseInt(itemId));
try {
for (var i = 0; i < obj.data.length; i++) {
if (obj.data[i].name === 'ID' || obj.data[i].name === 'Attachments') continue;
else {
console.log('Set ' + obj.data[i].name + ' value: ', obj.data[i].value);
item.set_item(obj.data[i].name, obj.data[i].value);//HERE IT BREAKS
}
}
item.update();
if (typeof obj.attachments !== 'undefined' && Object.keys(obj.attachments.urls).length > 0) {
var attachmentsUpCount = 0;
var attachmentsDelCount = 0;
for (var name in obj.attachments.urls) {
var aux = obj.attachments.urls[name];
if (aux.action === 'new') {
attachmentsUpCount++;
var listName = ListItems.listCacheWhitTitle[obj.list].get_title();
uploadFileSP(listName, itemId, aux.name, aux.file).then(function () {
attachmentsUpCount--;
if (attachmentsUpCount === 0 && attachmentsDelCount === 0)
auxDef.resolve();
}, function () {
auxDef.fail(arguments);
});
} else if (aux.action === 'delete') {
attachmentsDelCount++;
var attachments = obj.attachments;
for (var j = 0; j < attachments.get_count() ; j++) {
if (attachments.itemAt(j).get_name() === aux.name) {
attachments.itemAt(j).deleteObject();
attachmentsDelCount--;
}
}
}
}
if (attachmentsUpCount === 0 && attachmentsDelCount === 0)
auxDef.resolve();
} else {
auxDef.resolve();
}
} catch (args) {
console.error('Error try catch updateProperties. ' + args.message + ' ', args);
auxDef.reject(arguments);
}
return auxDef;}
Solved! Taking into account the comment of LZ_MSFT and although I thought that the error was not in the values that it set ... It was not like that. When using a new library to handle the lookups when I got the value of it and set them it was not coming with the form 'Id # Value' so I had a validation error! And falling into the cath and breaking the promise, the data was never sent to the server and I could not account. It was a few days! Thanks
For the registration: I do not have problems for making set_item of more than one field.