4 Replies Latest reply: Mar 26, 2013 11:51 PM by Kevin Hammer RSS

    How to use JS API in Extension

      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.

        • Re: How to use JS API in Extension

          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;
                          var varlist = "";
                          //Let pids = =concat(distinct [$(=$(%%v_SelectedKey($1)))], '$(%%v_SelValuesDelimiter)', [$(=$(%%v_SelectedKey($1)))]);
                          for(var i = 0; i < variables.length; i++){
                              if (variables[i].name.indexOf("v_SelectedKeyValues") != -1) {
                                  varlist += variables[i].name + " = " + variables[i].value + "\n";
                          //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.

          • Re: How to use JS API in Extension

            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:


            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!