Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am an experienced javascript developer building my first QlikView 11 extension for a customer.
The customer has provided me with a sample QVW file that has 5 Text Objects on a sheet. The text is set to display "=$(%%v_SelString1)" in the first Text Object and on to "=$(%%v_SelString5)" in the fifth.
That gets rendered to the screen as a string that contains some data I need to get to in my extension. I'm not going to have those Text Objects in the sheet or document at all in a final version of the QVW that includes my extension.
How can I get the value of =$(%%v_SelString1) using the JS API?
Thanks for any help that can be offered in explaining what "=$(%%v_SelString1)" is and how to get to it from my extension javascript code.
I found this in another post and am able to get it to find the variables I need:
var doc = Qv.GetCurrentDocument(); var varsRetrieved = false; doc.SetOnUpdateComplete(function(){ if(!varsRetrieved){ Qv.GetDocument("").GetAllVariables(function(variables){ var varlist = ""; //Let pids = =concat(distinct [$(=$(%%v_SelectedKey($1)))], '$(%%v_SelValuesDelimiter)', [$(=$(%%v_SelectedKey($1)))]); for(var i = 0; i < variables.length; i++){ if (variables.name.indexOf("v_SelectedKeyValues") != -1) { varlist += variables.name + " = " + variables.value + "\n"; } } alert(varlist); //alert("pids" + " = " + pids + "\n" + varlist); }); varsRetrieved = true; } });
the problem that remains is that it doesn't give me a value, but an equation instead:
concat(distinct [$(=$(%%v_SelectedKey($1)))], '$(%%v_SelValuesDelimiter)', [$(=$(%%v_SelectedKey($1)))])
I need to know how to get the value of that equation in my extension script.
Change your variable, add a "=" sign at the start, as the first character.
I'm not sure what you mean. How would I, for example, get the value of a document variable named "%%v_SelString1" to display in an alert?
I made some progress on this by adding a text field to the definition likes this:
<Text Initial="" Expression="=$(%%v_SelectedKeyValues(1))"/>
Turns out the "variable" I was after is actually a function, and i need to pass in an index value as a parameter.
I was able to print the value using this line in my extension script:
this.Layout.Text0.text
While thats good progress and i'm learning, I still haven't solved my problem. I need to get the value of %%v_SelectedKeyValues(n) from my extension script.
Thanks for the help so far!