mardi 3 février 2015

How to get a list from a list collection, getByTitle not working



So I retrieve a bunch of lists from host-web and put them into a listCollection similar to as outlined here.


Then I try to access a specific list called TestList. However, I can't access it from the listCollection using getByTitle("TestList"). It will give me a list with no information from the list I'm retrieving.


However, if I loop through an enumerator until I find a list with the title TestList, I can use that.


Does anyone know why this doesn't work?



var testList = listCollection.getByTitle("TestList");
console.log(testList);


But this does?



var listEnumerator = listCollection.getEnumerator();

while (listEnumerator.moveNext()) {

oList = listEnumerator.get_current();

if (oList.get_title() == "TestList") {
console.log(oList);
}
}


These console.log yield the respective outputs. See how the top one doesn't have an Object inside the ClientObjectData. Why is that? What am I missing?


Thanks enter image description here








0 commentaires:

Enregistrer un commentaire