Qlik Community

Ask a Question

New to QlikView

If you’re new to QlikView, start with this Discussion Board and get up-to-speed quickly.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Specialist
Specialist

prj folders not moving the variable values

Hi Team,

I already read some threads about moving the variable values in prj folders.I created the same code which is explained in this http://community.qlik.com/docs/DOC-7168

But it seems not working for me at the moment.Let me explain what I am doing here.

I have used the same code in the layout,and ran the script.I had copied the prj folder to another location and there I created a new qlikview document with the same name(except prj) and ran the script again..Here I don't see the variable values in the layout as well as in the new qvd.But I can see the variable values in the qvd which was generated in my original location.

Could you please check and confirm what I am doing wrong here.

Thanks & Regards

Jeba

1 Solution

Accepted Solutions
Partner
Partner

Try this :

LET vDocumentPath = DocumentPath();

VariableNames:

LOAD

  [Name] as VariableName

FROM  $(vDocumentPath) (XmlSimple, Table is [DocumentSummary/VariableDescription]);

FOR i=0 TO NoOfRows('VariableNames')

    LET varName = Peek('VariableName', $(i), 'VariableNames');   

    LET varValue = $(varName);

         

   Variables:

   LOAD // Load the variable name and value into a table

      '$(varName)' AS VariableName,

      '$(varValue)' AS VariableValue

   AutoGenerate 1;                    

NEXT

STORE Variables INTO Variables.qvd (QVD);

DROP Tables VariableNames, Variables; // Drop the tables

View solution in original post

7 Replies
Partner
Partner

Hello,

I roughly remember as this may be related to QV version.

Test with a newer one if it's kind of older.

BR

Serhan

Hi

The document in How to store and recover variables contains two script snippets for you to incorporate on your code. You run the Store Variables part from a QV document that has variable values. You run only the Recover Variables tab to recover the variable values.

In your case i think you are running the entire script in the new location, so you are writing empty values to the QVD and then reading those empty values.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Specialist
Specialist

Hi Jonathan,

I am into SVN testing project.I am only moving the prj folder and creating a new qlikview document from there from the moved prj folder.

Not sure how to move only the qvd which was generated in the previous instance

Could you please guide

Regards

Jeba

Specialist
Specialist

Variable values are not stored in the project folder XML files, hence it is not possible to recover them if the QVW file gets deleted or corrupted.

To prevent the loss of variable values, the current variables can be exported to a QVD during application reload. The QVD can then later be used to recover the previous variable values.


Store all application variables to QVD file

The below script loads all defined variables from the AllProperties.XML file in the QlikView project (PRJ) folder. This script should be loaded along with the application linked to the PRJ folder, since the variable values are stored in that QVW file. All the variables found in the AllProperties.XML are extracted and stored into a QVD file called Variables.qvd.

To be on the safe side this script could be included all reloads, so that the variables can be restored even if the QVW file gets corrupted or deleted.

VariableNames:

LOAD Name AS VariableName

FROM [MyApplication-prj\AllProperties.xml] (XmlSimple, Table is [AllProperties/VariableProperties/VariableProperties]);

FOR i=0 TO NoOfRows('VariableNames')

    LET varName = Peek('VariableName', $(i), 'VariableNames');           

    LET varValue = $(varName);

         

   Variables:

   LOAD

      '$(varName)' AS VariableName,

      '$(varValue)' AS VariableValue

   AutoGenerate 1;                    

NEXT


STORE Variables INTO Variables.qvd (QVD);

DROP Tables VariableNames, Variables;


Restore all application variables from a QVD file

The variables stored in the QVD file in the above example can be restored by the principle below. The QVD is loaded and then the variables are picked out one by one and defined in the application. This script should only be executed on loads where the variables should be recovered.


Variables:
LOAD VariableName,
     VariableValue
FROM Variables.qvd (qvd);


FOR i=0 TO NoOfRows('Variables')

            LET vVar = Peek('VariableName', $(i), 'Variables');
            LET vVal = Peek('VariableValue', $(i), 'Variables');
          
            LET '$(vVar)' = '$(vVal)';

NEXT
Specialist
Specialist

Hi Abhijit,

Creating the variable qvd and calling the same qvd works fine already.

However in this scanario I am not loading the qvd back again.I am only moving the prj folder and creating the layout from the prj folder.As Jonathan said I am reloading the same layout with empty values.

Is there any other alternate way to achieve this?

Regards

Jeba

Specialist
Specialist

any help will be highly appreciated

Partner
Partner

Try this :

LET vDocumentPath = DocumentPath();

VariableNames:

LOAD

  [Name] as VariableName

FROM  $(vDocumentPath) (XmlSimple, Table is [DocumentSummary/VariableDescription]);

FOR i=0 TO NoOfRows('VariableNames')

    LET varName = Peek('VariableName', $(i), 'VariableNames');   

    LET varValue = $(varName);

         

   Variables:

   LOAD // Load the variable name and value into a table

      '$(varName)' AS VariableName,

      '$(varValue)' AS VariableValue

   AutoGenerate 1;                    

NEXT

STORE Variables INTO Variables.qvd (QVD);

DROP Tables VariableNames, Variables; // Drop the tables

View solution in original post