0

I have a problem with QlikView in the browser: I have a listbox and try to access it using an initialize script.

The script is registered by using the InitWorkbench function, using its BodyOnLoadFunctionNames parameter. So far, this works, and the initializer is run at startup.

Inside the initializer I try to do the following:

var doc = Qv.GetCurrentDocument();
var listbox = doc.GetObject('LB01');

Afterwards, when I have a look at listbox.Type, unfortunately it is undefined. If I delay execution of this query, it correctly says LB, hence apparently the query works - but only when it is executed delayed.

So, obviuosly there's a timing problem, and it seems as if the initializer runs too early (or I am doing something wrong).

Can anybody point out what the solution is (or give me a hint on what I am doing wrong)?

Golo Roden
  • 140,679
  • 96
  • 298
  • 425

1 Answers1

0

Okay, I've found the solution: The internal update function did not run yet, and all the values are only available once this function ran, so you need to provide a callback to the call to GetObject (that gets called after the update function):

var doc = Qv.GetCurrentDocument();
var listbox = doc.GetObject('LB01', function () {
  console.log(listbox.Type); // => 'LB'
});
Golo Roden
  • 140,679
  • 96
  • 298
  • 425