Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator III
Creator III

saving changes in the variables on the server

Hi,

In my Desktop Qlikview I created a QV-document which includes actions.

For instance, there are actions like:

Set variable: Test

Value = 1.

I've published the file on the server. I'm testing it via web-browser at the moment.

I see that if the user pushes the button with an embedded action (variable 'Test' gets the value = 1), then they close the file, reopen it and see that the change in the variable hasn't been saved (Test = 0).

Is it possible to save user settings?

Thank you in advacne,

Larisa

3 Replies
Highlighted
Employee
Employee

Re: saving changes in the variables on the server

Can you please make sure that the Session Recovery option in the QMC is enabled and check again?

You'll find it in the System --> Setup --> Qlikview server --> Document tab

Thanks

Highlighted
Creator III
Creator III

Re: saving changes in the variables on the server

I'll check it thank you.

Highlighted
Contributor
Contributor

Re: saving changes in the variables on the server

Here is an example saving variables to a txt file:

Sub ExportVariablesToTxt

Set doc = ActiveDocument

Set wbFilename = ActiveDocument.GetVariable("ArquivoParametros")

If wbFilename is Nothing then

' The variable that stores the location of the variables Txt file does not exist

MsgBox "The required variable 'ArquivoParametros' does not exists!", 16, "Error"

Else

If Instr(Lcase(wbFilename.GetRawContent), "txt") = 0 then

' The variable exists, but does not contain a valid Txt filename (based on looking for the 'txt' part)

MsgBox "No valid Txt filename specified in variable 'ArquivoParametros'", 16, "Error"

Else

'Get the path of the current QVW      

        QvwPath = Left(ActiveDocument.GetProperties.Filename, InStrRev(ActiveDocument.GetProperties.Filename, "\"))

      

      

        ' Initialize txt, open the file and get a reference to the Variables

Set objFS = CreateObject("Scripting.FileSystemObject")

strFile = QvwPath & wbFilename.GetRawContent

Set objFile = objFS.CreateTextFile(strFile,True) 

   

      

Set vars = ActiveDocument.GetVariableDescriptions

         

r = 2

      

For i = 0 to vars.Count - 1

      

Set v = vars.Item(i)

            ' Exclude all QlikView specific variables

If not v.IsConfig and not v.IsReserved then

    objFile.WriteLine(v.Name & "=" & v.RawValue)

                   

r = r + 1

end if

            

       next

objFile.Close

         

End If

         

End If

End Sub

Sub ImportVariablesFromTxt

Set doc = ActiveDocument

Set wbFilename = ActiveDocument.GetVariable("ArquivoParametros")

If wbFilename is Nothing then

' The variable that stores the location of the variables Txt file does not exist

MsgBox "The required variable 'ArquivoParametros' does not exists!", 16, "Error"

Else

If Instr(Lcase(wbFilename.GetRawContent), "txt") = 0 then

' The variable exists, but does not contain a valid Txt filename (based on looking for the 'txt' part)

MsgBox "No valid Excel filename specified in variable 'ArquivoParametros'", 16, "Error"

Else

'Get the path of the current QVW      

        QvwPath = Left(ActiveDocument.GetProperties.Filename, InStrRev(ActiveDocument.GetProperties.Filename, "\"))

      

Set objFS = CreateObject("Scripting.FileSystemObject")

strFile = QvwPath & wbFilename.GetRawContent

Set objFile = objFS.OpenTextFile(strFile) 

      

 

Do Until objFile.AtEndOfStream

srtLine=objFile.ReadLine

srtVar=Left(srtLine,Instr(srtLine,"=")-1)

srtValue=Mid(srtLine,InStr(srtLine,"=")+1)

            doc.CreateVariable(srtVar)

              Set v = doc.Variables(srtVar)

              v.SetContent srtValue, true

Loop

objFile.Close

         

End If

         

End If

End Sub