Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Persistant user entered variables

My application is 100% web delivered via AJAX.

In my application, I would like to allow the users (or a particular user, which I can control with section access) to change a value that's stored in a variable. (well, several variables, actually, but that's semantics)

Currently, when a user makes a change to one of these exposed variables, that change is cleared when the browser session is closed, or when the user logs out.

How can I make these changes persist between sessions?

How can I allow this administrator level user to make changes to their dashboard variables?

Thanks!

9 Replies
vgutkovsky
Master II
Master II

Ryan,

I don't think that's possible since opening in server by definition opens the QVW in read-only mode. Therefore, no changes (including setting variables) is permanent. I sometimes get around this challenge by outputting variables to a text file, which the QVW then reads in during a reload. The output to a text file can be implemented via standard VBScript macro (see API Guide for more details) as long as macro execution is allowed on your QVS. Of course, a reload is necessary to read in changes, so this solution may not work in your particular case either...

Regards,

pover
Luminary Alumni
Luminary Alumni

Use inputfields instead of variables. More testing is required to see if it is persistant per user or per machine but they are persistant. You can also save the values of inputfields in bookmarks.

So, instead of variables, I would create a inline table with a list of are now your variables and another column that contains the value and is declared an inputfield. Then to use the variables in formulas would involve using set analysis. (eg. only({$<Variable_Name={'Variable1'}>} Input_Value).

I hope that works.

Not applicable
Author

Hey Gents,

Neither solution really works, but together, they're fabulous.

Input fields are persistent between sessions, but my nightly script reload will wipe out the changes when the script re-runs. Their user experience is totally unintuitive, and to top it all off, they seem to behave very strangely in AJAX. (at least in my current version of 9)

I can't script to write out to a server file (as far as I can tell) because the script runs on the client side. Ie: I would attempt to write this file to the client's local machine… or at least this is my understanding.

My solution might be a little over engineered, but here ya go:

I created a button called 'Save Targets'.

When the user clicks the button, a script executes (which I tried to write first in VBScript, but didn't work in AJAX… Noting that it's not called AVBAX, I wrote it in Jscript instead, and now it works)

The script takes all of the values from the variables, and crams them into input fields.

Another script executes when the application is opened that takes the values from the input fields, and crams them back into the variables. (there is a 'Cancel' button that does the same)

Now my user's experience is unchanged from the familiar variable experience, and they have the option to mess about with the calculator, and choose to save their changes, or not, and it all actually works in AJAX.

Oh, the other wrinkle is now, in publisher, I've set the nightly reload task to 'Partial Reload' and specified all tables, except the one which loads the Variables as input fields as 'REPLACE' loads, and Bob is officially my uncle.

Thanks for the assist!

vgutkovsky
Master II
Master II

Wow, that is an extremely complicated solution! Glad it works for you though!

Cheers,

pover
Luminary Alumni
Luminary Alumni

Impressive. You've got it covered.

Just a comment to whoever might read this in the future, that you can make a marco to write out to a server file as Vlad's solution suggests with the ServerSideExport and ServerSideExportEx functions. It worked alright for me to save user comments on a Balanced Scorecard, but of course the variables didn't have to be persistant like in this case.

vgutkovsky
Master II
Master II

Karl,

I actually usually just use FileSystemObject to write out to a UNC path\text file. But I suppose a ServerSideExport would work too if you set it up a little differently.

colinh
Partner - Creator II
Partner - Creator II

Hi Ryan

There was a similar thread a few days ago, where I suggested that you can save variable values using bookmarks:

http://community.qlik.com/forums/p/34622/134987.aspx

You seem to have your problem solved, but this might be interesting to you anyway.

Not applicable
Author

Yeargh, I didn't see the ServerSideExport methods. *sigh* that would have made my life a ton easier.

In fact, I may go back, and re-work my solution... because it's a tad silly as is.

Bookmarks are a great idea, but I'd rather not have a bookmark the user doesn't recognize, or that could be deleted.

UNC pathing doesn't work either, as the document is being accessed via the wild wooly internet, and has no access to the server.

Not applicable
Author

Karl Pover wrote:

Use inputfields instead of variables. More testing is required to see if it is persistant per user or per machine but they are persistant.

[...]

Input fields refer to variables, don't they?  I don't understand what the difference is.  I need to have so-called persistent input values across sessions, and input field values do not persist between sessions for me.  Is there a document preference I'm missing?

It would be great to achieve this functionality without writing and reading files on the server side!

UPDATE:

Oh, wait: you're referring to fields modified by inputfield() during load, right?  That is different from an Input Box, which is what I'm trying to use to let the user enter a persistent value.  But the inputfield value will still be overwritten by reloads, as you mentioned.  😞