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: 
Frédéricdh
Creator II
Creator II

Variables

Hello,

 

how to declare a script variable, which value depend from a value from a selection in a sheet Object and then I load the script new.

 

your Help will be so welcome.

 

thanks in advance

 

Frédéric

Labels (1)
3 Solutions

Accepted Solutions
Nicolae_Alecu
Creator
Creator

Hello,

You can use Input Variable Object. 

1. Declare a variable in Vizsualization part: 
2. Create Input Variable Object linked to this variable.

Nicolae_Alecu_0-1710521292051.png

3. Use the variable in script.

Ex: Trace '$(vInputVariable)'; 

Nicolae_Alecu_1-1710521390088.png

Good Luck! 



 

View solution in original post

Nicolae_Alecu
Creator
Creator

If you use GetFieldSelections() to define the variable (vVar1), then you can do this: 

1. Define a second variable (vVar2) 
2. Add a button object
3. Add a "Set Variable Value" action and set vVar2 = '$(vVar1)' 
4. Add a "Reload Data" action to the same button 
5. Select a value
5. Click Button 

Have a nice day. 

View solution in original post

Frédéricdh
Creator II
Creator II
Author

Hello, now it works and without an InputBX, just with the button and the set variable

View solution in original post

6 Replies
Clement15
Partner - Creator III
Partner - Creator III

Hello, it is not possible to change the value of a script variable according to selections. However, you can create variables directly in the visualization part that you can control with the variable input component.

Variable input control | Qlik Sense on Windows Help

 

Nicolae_Alecu
Creator
Creator

Hello,

You can use Input Variable Object. 

1. Declare a variable in Vizsualization part: 
2. Create Input Variable Object linked to this variable.

Nicolae_Alecu_0-1710521292051.png

3. Use the variable in script.

Ex: Trace '$(vInputVariable)'; 

Nicolae_Alecu_1-1710521390088.png

Good Luck! 



 

Frédéricdh
Creator II
Creator II
Author

Good, but I use the function GetFieldSelections to have my value in qlik and then in the script I use the variable REFNUM but the script use the function and not the value behind.

Nicolae_Alecu
Creator
Creator

If you use GetFieldSelections() to define the variable (vVar1), then you can do this: 

1. Define a second variable (vVar2) 
2. Add a button object
3. Add a "Set Variable Value" action and set vVar2 = '$(vVar1)' 
4. Add a "Reload Data" action to the same button 
5. Select a value
5. Click Button 

Have a nice day. 

Frédéricdh
Creator II
Creator II
Author

No it doesn't work for me, i don't understand why but in the script the error is that in the Where clause, the variable vVar2 is blank.

Frédéricdh
Creator II
Creator II
Author

Hello, now it works and without an InputBX, just with the button and the set variable