Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm trying to assign the value of a variable created and assigned in the load script for an app to a javascript variable in a qlik sense extension object. I've been looking for hours and have tried many different syntaxes, but cannot get any of them to store the script variable value to an extension object javascript variable.
I can see the variable inside Qlik desktop itself, but just can't seem to use it correctly.
In the load script:
SET vTestVar='VarValue';
tried the following in the extension object javascript paint routine:
var app = qlik.currApp();
var v2 = app.variable.getContent("vTestVar");
var v3 = $(vTestVar);
var v4 = '$(vTestVar)';
var v5 = '=$(vTestVar)';
Any help would be truly appreciated.
To get the variable content you need to use a callback function, a la:
var v2 = '';
app.variable.getContent('vTestVar', function ( reply ) {
//alert( JSON.stringify( reply ) ); // check the content, if necessary
v2 = reply;
} );
It will run asynchronously compared to the following statements.
Hence, also v3, v4 & v5 should be inside the function - otherwise they might be empty, if the callback function has not run.
And $() is only used in Qlik-script code and not in JavaScript code 🙂