Forum Discussion

mgreen's avatar
mgreen
Contributor
6 years ago

FindAll returns blank in log - help!

Hi All -  Trying to get back some data when doing the "FindAll" method.  "Find" seems to work fine and prints to the log fine.  Whenever I run FindAll, it does not give me any error - but the log i...
  • RUDOLF_BOTHMA's avatar
    RUDOLF_BOTHMA
    6 years ago

    further to cunderw 

     

    You may need to explicitly convert the items that FindAll returns to an array

    function Find() {
    Results = NameMapping.Sys.browser.page.nav.FindAll("contentText", "*", 1, 1000).toArray();
    for(var i=0;i<Results.Length;i++){
      Log.Message(Results[i].MappedName);
      //you could break early:
      if(Results[I].MappedName=='TableName')  {
        break;
      }
    } 
    } //I tend to use for(var i=Results.length-1;i>=0;i--) because TC returns the find results from the leaf furthest down the hierarchy first and traverses up and in the majority of cases I want to look from the top level down - personal preference though