Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Delete variables in loading scripts

Hi all,

Is there a way to do the same thing than the following macro by the very beginning of the loading script?

 

Sub cleanVariables
     Set VariableCollection = ActiveDocument.GetVariableDescriptions
     For i = 0 to VariableCollection.Count - 1
          Set tempVar = VariableCollection.Item(i)
          tempVarName = tempVar.Name
     ActiveDocument.RemoveVariable tempVarName
     Next
End sub

The idea is to flush the application from every variable when the reload button is engaged.

Thanks in advance.

8 Replies
Not applicable
Author

VarName =;

or

VarName = null();

Regards,

Ricardo

Not applicable
Author

Hi Ricardo,

this will flush a known variable, but will not do the same thing than the macro.

The macro is looking for any existing variable in the document then remove it.

Anonymous
Not applicable
Author

Hi,

I use the commands above to delete the temp variables in loading script (QV 11.0 SR2). The values of the variables will be deleted, but the empty variables stay in the Variable Overview.

This is a datamart and the variables will be not used in frontend.

How can I delete the variables in Variable Overview with loading script?

Thanks

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

If the following conditions are met, the variable will not persist into the front end:

  • The variable does not exist before the reload (in other words it is created by the load script)
  • The variable is set to null before the load script is terminated (eg Set vVar=; )

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

ok, if the script runs some times variables exist already. This sentence was helpfull:

"The variable does not exist before the reload (in other words it is created by the load script)"

Thanks

bimartingo
Contributor III
Contributor III

In any case, you need to (eg)  set vVar=;

this leads me to another possible situation: suppose you create the variable declaring it on the script but forget to assign the empty value and after loading and using the frontend, you save the document, storing the variable into it. In this case, I think, whether you insert the [ set vVar=; ] statement in the script, you ought to delete it from the document using the Document Property window.

Not applicable
Author

You are correct Martin. You created variable in the script and refresh the app. So you can see the the variable on the Variable window (Ctrl+Alt+v). If you delete the variable from application, you need to assign null or nothing in the script. If the variables already on UI, you shouldd have to delete from UI as well.

stantrolav
Partner - Creator II
Partner - Creator II

Here is my script that dont creates variables in Application after script ends. Try it in your case.

Now = Now();

ReloadTime = ReloadTime();

DocumentPath = DocumentPath();

DocumentTitle = DocumentTitle();

LOAD * INLINE [

    AppPath, AppReloadTime, AppDocumentPath, AppDocumentName

    $(QvWorkPath), $(Now), $(ReloadTime), $(DocumentPath), $(DocumentTitle)];

Now = Null();

ReloadTime = Null();

DocumentPath = Null();

DocumentTitle = Null();