Qlik Community

QlikView Extensions

Discussion Board for collaboration on QlikView Extensions.

Highlighted
Not applicable

Get value of QV variable to use in JavaScript

Hello everyone,

how can I get the value of a single variable and use it in Javascript?

I need to get the current selection of a field from a variable and use this value as a string in order to do a if/else comparison.

Example:

varQV = Only(Field)

In JS I then want to do: if (varQV ="string of varQV") ....

I tried with the mydoc.GetAllVariables function but I can't get the string of the field only the definition [Only(Field)]

Hope you can help.

Thank you,

Thorsten

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Get value of QV variable to use in JavaScript

Unfortunately it is not possible to get the evaluation of a variable using the GetAllVariables function, only the definition is available in the returned object.

However you can get the evaluation of the variable by using it in a Text expression of your extension property. In your definition.xml file, add :

<Text Expression="=varQV" />

You will then be able to get the variable value in your javascript code with the following code in your extension method:

var varQV = this.Layout.Text0.text;

2 Replies
Not applicable

Re: Get value of QV variable to use in JavaScript

Unfortunately it is not possible to get the evaluation of a variable using the GetAllVariables function, only the definition is available in the returned object.

However you can get the evaluation of the variable by using it in a Text expression of your extension property. In your definition.xml file, add :

<Text Expression="=varQV" />

You will then be able to get the variable value in your javascript code with the following code in your extension method:

var varQV = this.Layout.Text0.text;

warfollowmy_ver
Contributor III

Re: Get value of QV variable to use in JavaScript

Hello jgeorge, it does not work for me.

I do as they write everywhere. But nothing happens.

QV 12 November release.

Could you throw off the finished two files (.xml and .js)so that I can understand the error?