Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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

5 Replies
tresesco
MVP
MVP

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.

tresesco
MVP
MVP

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.