Promise returns undefined
Hey there,
I'm struggeling with a function of mine and I dont' quite know why, as this method seems to have worked so far for other functions. Basically I'm getting Objects from a SharePoint List and return all the Values in common. Somehow in my returned variable my "Result" is always undefined. When I make a breakpoint at the deferred.resolve() result is correctly defined but somehow it doesnt get out. Maybe someone has an idea where I'm doing it wrong.
I also tried the resolve in a seperate chained done. Still the same behaviour though :(
Thanks in advance and
Greetings Chris
- }, getFilteredListMultiple: function(ListName, AndOrFilter){
-
- var deferred = new $.Deferred();
-
- var result;
- var andFilteredLists = [];
-
- $(AndOrFilter).each(function(index){
- andFilteredLists[index] = aceSpListLookup.list.getFilteredList(ListName, this);
- })
-
- $.when.apply(null, andFilteredLists).done(function(){
- result = andFilteredLists[0].Result.responseJSON.d.results;
- for(i=0; i<andFilteredLists.length-1; i++){
- result = customGeneralFunctions.elementsInCommon(result,andFilteredLists[i+1].Result.responseJSON.d.results);
- }
- deferred.resolve();
- });
- return deferred.promise({Result: result});
- }
- }