0 Replies Latest reply: Feb 28, 2014 12:24 PM by Omer Demir RSS

    QlikView Ajax - GetAllObjects function in a loop doesn't operate properly

    Omer Demir

      Hi,

       

      I'm trying to get all obejcts in several documents. I have following code but It doesn't work properly. While loop iterates firstly omitting the GetAllObjects function, and then it operates the function. How could this be solved?

       

      function fillArray()
          {
           var ln = docNames.length - 1;
              while (ln > 0)
              {
                  myArray[ln] = [];
                  var doc = Qv.GetDocument(docNames[ln]);
                 
                  doc.GetAllObjects(function (objects)
                  {
                      alert("Inside GetAllObjects");
                      for (var i = 0; i < objects.length; i++)
                      {
                          alert("Inside For. j=" + j + " and i=" + i);
                          myArray[ln][i] = [];
                          var obj = objects[i];
                          var id = obj.id;
                          var caption = obj.caption;
                          var type = obj.type;
                          myArray[ln][i][0] = docName;
                          myArray[ln][i][1] = id;
                          myArray[ln][i][2] = caption;
                          myArray[ln][i][3] = type;
                      }
      
      
                  });
                  ln = ln-1;
              }
      }