Forum Discussion

Kostja's avatar
Kostja
Contributor
10 years ago

Get each iteration in its respective table

Hey everybody,   i got a new problem.   I write my scripts and as soon as they finish i have an event handler which writes everything into database line by line. Everything works fine with just 1...
  • Kostja's avatar
    Kostja
    10 years ago

    I can't believe it myself, but i did it. After 3 days of trying i found the solution.

     

    I tested it with 2 and 4 iterations and every log goes in its own table.

     

    My solution -->

     

    function ExportLogItem(ALogItem)
    {
      var i;
      
      // Exporting log item's data
      for(i = 0; i < ALogItem.DataCount; i++)
      {  
        if((aqString.Find(ALogItem.Name, 'Iteration')) != -1)
        {
          var curr = Project.TestItems.Current.ElementToBeRun;
          
          if((aqString.Find(curr.Caption, 'Create_DB')) == -1)
          {      
            var proIter = Project.TestItems.Current.Parent.Parent.Iteration;
                    
            if((aqString.Find(ALogItem.Name, proIter)) != -1)
            {
              ExportLogData(ALogItem.Data(i));
            }
            else
            {
              return;
            } 
          }
        }  
        else
        { 
          ExportLogData(ALogItem.Data(i)); 
        }
      }
      // Exporting child log items
      for(i = 0; i < ALogItem.ChildCount; i++)
        ExportLogItem(ALogItem.Child(i)); 
    
    }