Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

How to use load script variables in qlik sense extension objects

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.

1 Reply
Not applicable

Re: How to use load script variables in qlik sense extension objects

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 :-)