I have a dynamically generated array with IDs of different items and different lists.
What I want:
Return custom fields of every item in my array.
The Problem:
No Problem until an item is deleted. Then I'll get the following error:
Item does not exist. It may have been deleted by another user.
My idea:
Maybe there is an easy option to check if an item exists or not. The array with the item IDs can become large, with more than 200 items of different lists. So I think it's not a good idea to make an Ajax-Request for every single item. Isn't there a better solution?
My Code:
var context = SP.ClientContext.get_current();
for(var i in items){
var web = context.get_web(items[i]['webId']);
var list = web.get_lists().getById(items[i]['listId']);
var item = list.getItemById(items[i]['itemId']);
for(var j in columns){
if(columns[j].getToLoad('web').length > 0){
for(var k in columns[j].getToLoad('web')){
context.load(web, columns[j].getToLoad('web')[k]);
}
}
if(columns[j].getToLoad('list').length > 0){
for(var k in columns[j].getToLoad('list')){
context.load(list, columns[j].getToLoad('list')[k]);
}
}
if(columns[j].getToLoad('item').length > 0){
for(var k in columns[j].getToLoad('item')){
context.load(item, columns[j].getToLoad('item')[k]);
}
}
}
}
context.executeQueryAsync(
buildTable.bind(this, items),
function(a, b){
console.error('ERROR: ' + b.get_message());
}
);