lundi 16 février 2015

Handling if list doesn't exist under sub web in SharePoint (JavaScript)


I'm receiving every list (and a item specified by ID: 1) under a few sub webs.


I push every subweb:



var list = webs.get_lists().getByTitle('MyCustomList');
listUnderSubWebs.push({
'listItem': list.getItemById(1)
});


And then performs load (inside the while-loop for the subwebs):



context.load(listUnderSubWebs[listUnderSubWebs.length - 1].listItem);


And then outside the while-loop i perform the context.executeQueryAsync.


Everything works fine if the list exists, but if it doesn't the error handling function is executed.


How can I check this before? I want it to execute the success function even if the list doesn't exist (and handle the "list doesn't exist" error in the success function so I can proceed with the other sub webs). Now it just breaks.


Maybe that's not possible? Is there any way to solve this?





Aucun commentaire:

Enregistrer un commentaire