Promise returns undefined

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
  1. }, getFilteredListMultiple: function(ListName, AndOrFilter){
  2.       var deferred = new $.Deferred();
  3.       var result;
  4.       var andFilteredLists = [];
  5.       $(AndOrFilter).each(function(index){
  6.             andFilteredLists[index] = aceSpListLookup.list.getFilteredList(ListName, this);
  7. })
  8. $.when.apply(null, andFilteredLists).done(function(){
  9. result = andFilteredLists[0].Result.responseJSON.d.results;
  10. for(i=0; i<andFilteredLists.length-1; i++){
  11. result =                                                customGeneralFunctions.elementsInCommon(result,andFilteredLists[i+1].Result.responseJSON.d.results);
  12.                   }
  13. deferred.resolve();
  14. });
  15. return deferred.promise({Result: result});
  16. }
  17. }