Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am writing an extension that renders a google vizualization. On the same sheet as my extension, I have two listboxes that display data fields as normal.
From within my javascript I would like to be able to obtain a handle to these listboxes so that I can iterate over their data.
The API documentation says to use: 'Qv.GetCurrentDocument().GetObject(objectName)' where objectName is defined as 'The name of the object you want to append your callbackFn to.'
However, the problem I'm having is that I do not know the name of my objects in order to be able to reference them. I have tried the obvious things like using their objectId etc. but none of these are successful. No matter what I use for the objectName parameter, I don't get back a proper handle to the object:
Example 1
var mydoc = Qv.GetCurrentDocument();
var ch = mydoc.GetObject("LB02");
alert(ch.Layout.ObjectId);
Example 2
var mydoc = Qv.GetCurrentDocument();
var ch = mydoc.GetObject("Document\LB02");
alert(ch.Layout.ObjectId);
After running either of the above code samples, I expect to obtain an alert with the ObjectId of my listbox in order to prove I have obtained a correct handle. However, the alert box is always just blank.
Can anybody please advise on how I can find the internal QV name assigned to each object? Or perhaps an alternative way to get a hold of my listboxes from within my javascript?
Thanks,
Padraic
Hi Padraic, the GetObject-Function is asynchronous. You need to await the callback of this function with `SetOnUpdateComplete()`. https://help.qlik.com/en-US/qlikview-developer/12.1/apis/js+API/symbols/Qv.Document.html#SetOnUpdate... You could try something like this: var mydoc = Qv.GetCurrentDocument(); var ch = mydoc.GetObject("LB02"); ch.SetOnUpdateComplete(()=>{ alert(ch.Layout.ObjectId); });
I did, but get multiple submissions of the callback. How do I avoid that?
Dion