Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Looking for simple example to pass variables

    Hello all,

could anyone please provide a simple example how to get QV-Variables and assign them to javascript variables?

The posts I found are quite confusing and I can't get it to work with my script.

For example I want to pass a input box variable to javascript.

I use QV 11R6.

Thank you,

Thorsten

Labels (1)
5 Replies
tresB
Champion III
Champion III

Have you tried like:

Set var=ActiveDocument.GetVariable("Vriablename")       ?

Or

Set var=ActiveDocument.Variables("Vriablename")

Not applicable
Author

I put it in here:

Qv.LoadExtensionScripts(jsFiles, function () {

        Set varabc = ActiveDocument.GetVariable("var1") ;

    });

It gives me an error: expecting ";"...

A working example would be nice.

tresB
Champion III
Champion III

Sorry, I should have noticed earlier that you are looking for JS. The above code is VBScript. I am not sure if variable of a qv doc can be referred using JS in extension. May be Brian Munz can help you.

Not applicable
Author

Use the template provided by Stefan Walter here. Then use the add the following code inside your extension_Done function:

In the definition file set a text field:

<Text Label="MyVariable" TargetName="$(variable here)" Type="text" Width="30%" Expression=""/>

and use the text in your Script as so:

var myVariable= _this.Layout.Text0.text.toString();

Know you can use the MyVariable how ever you like in your script.

check your console = console.log(myVariable);

Not applicable
Author

Thanks, I think I got it right now.