Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
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

1 Solution

Accepted Solutions
Not applicable
Author

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;

View solution in original post

2 Replies
Not applicable
Author

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
Creator III
Creator III

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?