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: 
davequinn
Contributor III
Contributor III

Script variable value persists *after deletion*

Can anyone explain this? It feels like a bug to me, but i'm always ready to be corrected...
 
In Qlik Sense scripts it seems that once you have instantiated a variable, its value will persist in subsequent reloads
even if you delete the variable.
 
Simple example (create 2 variables, concat to a 3rd). Then delete one of the variables, but it is interpreted as if it was still there; the result is the same:
 
 
 

simple scriptsimple scriptresult after loadresult after loaddelete v2 ... makes no differencedelete v2 ... makes no difference

Furthermore it will persist in any copies of the App you make, even after you have made the deletion. ie Duplicating the App above, after deleting v2 will produce the same result.

Currently testing on June 2019 release of qliksenseserver : 13.32.2

All the best

David

Labels (5)
6 Replies
jpenuliar
Partner - Specialist III
Partner - Specialist III

To clear variable:

 

SET v1=;

SET v2=;

Vegar
MVP
MVP

If you create a variable in the script

Set var1 = 'Abc';

it will be available in the variable overview in the design edit mode.

If you later remove the row

//Set var1 = 'Abc';

The variable will still be available with the value 'ABC', but you can manually edit it in the variable overview in the design mode.

If you in the script instead empty the content of the variable, the variable will be available in the variable overview, but with no value.

Set var1 = ;

To keep an variable from appearing in the variable overview at all you need to always empty the content of the variable before the script ends. The var2 below will not end up in the variable overview and not be available during the next reload.


Set var2 = 'Xyz.qvd';

Load * from  '$(var2)' (qvd);

Set var2 = ;

 

 

davequinn
Contributor III
Contributor III
Author

sorry - you're missing the point. What I'm saying is that the variable seems to disappear, but the during the execution of the script any reference to it (even though it is no longer there) will return the value it had before you deleted it.

This can lead to some very odd behaviour in scripts!!!

I've just simplified it down as far as possible to highlight what appears to be a pretty serious bug!

Dave

Your comments have alerted me to something though - the variable still seems to exist in the App, even though it is no longer in the script. As  you can see in the screenshot below, v2 is no longer a script variable, but it is still there 😐

Annotation 2020-02-05 161449.jpg

Vegar
MVP
MVP

What do you mean when you write that "the variable seems to disappear"? What actions did you do to make it disappear?

PS: If the variable is available in the app then it is also available in the script. DS

Try this and see if you still get the var2 value in the second iteration.

 

set v1 = 'variable 1';
set v2 = 'variable 2';
LET v3 = v1 & ','& v2;
set v2=;

LOAD 
1 as Iteration,
'$(v3)' as V3
AutoGenerate 1;

LET v3 = v1 & ','& v2;
LOAD 
2 as Iteration,
'$(v3)' as V3
AutoGenerate 1;

 

 

davequinn
Contributor III
Contributor III
Author

Hi  Vegar,

As in the original post, I deleted the 2nd line - so there is no assignment of v2. 

However, I now understand the mechanism at work here better - ie that the script variable has migrated into the App.

And I can see how to work around it - you delete it from the variables panel in the App...

But it still feels very wrong! This automatic migration from script to app makes me very uncomfortable; Its like the App has a sort of homeopathic memory of all variables that were ever used at some point in its past! 

It can lead to some very unexpected behaviour in load scripts if you aren't aware. I have Apps which have been in development for years, undergoing countless revisions and often being duplicated to serve as the basis for new Apps.

I don't think this needs any further discussion, but in any other context  I would describe it as a bug  - where else would you expect to have to delete a variable not only from the code, but also the executable?

Thanks for your help,

Dave

Vegar
MVP
MVP

I see your point, but there are also advantages from having it this way. It might help you understand the concept if you see the script and the gui as an unity and not two separate entities.