Discussion Board for collaboration related to Creating Analytics for QlikView.
I have a variable in a document that is a date used in set analysis. The user selects the date in a calendar object, which is directly tied to the variable. With a reload time of every few minutes, this date is reset while the user is interacting with the document. How can I make it to where, if the user has the document open, the variable will not change on reload? I want the variable to reset to its default, yesterday or now(0) - 1, but this is secondary to stopping the change on reload.
That's a tricky one, because you can't really check if a user has it open. If users were opening in QV Desktop, then the most obvious solution would be to not set the variable in the script at all. Then whatever the last value of the variable was when the document was saved would be kept. However, since users are opening in a thin client, you don't want to overwrite the value of the variable with the saved value since the saved value is not what they set, but rather is what was set when the QVW was saved by the developer.
The only other thing I can think to try is setting a server setting that is usually not modified:
Uncheck "Allow only one copy of document in memory." This might allow the user to finish his session with the variable that he set and will only open the refreshed version when he opens a new session. Of course, that means that he will be using old data too, not just the old variable value. I'd be interested to know if this works, so please post your results!
I have a theory that it might be possible to keep the value of the variable by somehow storing it, but I cannot quite wrap my head around how to do this. Store it in the script? Store it with a VBScript macro? Use the VBS macro to write to a file? One could write to the file whenever the user changed the variable. The reload script could then load the variable value from that file if it was not older than a set amount of time, say, an hour or similar. Thoughts?
The problem is that it's a user-set variable. You can definitely write logic (either script or VBS) to store a variable set in the main QVW, but I don't know of any syntax that would fetch a variable value set by a user. Plus, if you have 10 users setting 10 different values for the same variable at the same time, how would you backup each one and then restore it without causing conflicts? No, all things considered, I doubt that is possible...
I take it you don't want to try the solution I posted above because it would cause the user to be working with old data until he closes and reopens his browser?
Yes, that is true. I will test it to see how it works, but I am trying to provide a real-time dashboard. Our reload schedule is not constant yet, but it is a goal we are trying to reach. How nice would it be to just leave QlikView open or on a display monitor and see the performance of the business evolve in real time?
Yeah, I see your point...unfortunately I don't know of a way to provide that while still keeping user variables intact. Like I mentioned, I suspect that if you just don't set variables at all in the script it will default to the last-saved value by the developer. But I could be wrong; as an experiment, try taking out the script LET/SET statements and see what happens. If that doesn't work, post here again and maybe someone else can weigh in with other ideas?
I am not setting the variable using LET/SET. It just has a value through the variable manager. However, I think I have a strong lead on the file-writing approach. Check out this little line from the API Guide QVW:
Now all that remains is the research on which VBScript methods to use for file reading, writing, and creation/modified time measure, along with some security settings.
I'm experiencing exactly the same issue, on partial reload when pushed from server it resets variables in User's IE version and hence resets visible/hidden objects.
Has anyone solved this issue in last 2 years? I'm using QV11.2 SR2.
My thanks in advance
I have come across a possible workaround that is working in my environment.
In the document properties/variables tab, for each of the user variables i have ticked the box for "Include in Bookmarks". After several document reloads using publisher the variable values are being retained after each refresh. I was having a similar issue with Date variables changing back to defaults and now it appears fixed.
Note: You need to reload it a first time, then change your variables and reload again to see the changes is working.