4 Replies Latest reply: May 20, 2017 4:02 PM by Павел Никифоров RSS

    How to get the value of a variable with a widget?

      Hello everybody,


      I want to create a widget which gets and sets the value of a variable by using a drop-down list in Qlik Sense.

      I could realize a drop-down list which sets a variable by using the setContent method from the Variable API. However, I have a problem with getting the value of a variable since the appropriate methods from the Variable API use a callback function. Is there a possibility to realize such a widget?

      I am new to Qlik Sense development and I have some basic knowledge in AngularJS.

      Thanks a lot in advance for your responses.


      Kind regards,


        • Re: How to get the value of a variable with a widget?
          Robert Hoekstra

          Hi Leon,


          I am also interested in knowing if it possible to use widgets in order to achieve such behavior.

          Did you find anything?


          Many thanks.


          Best regards,


          • Re: How to get the value of a variable with a widget?
            Stefan Walther


            this can currently not be achieved (based on Widget in Qlik Sense 3.0). But we are soon publishing a new API in Qlik Sense 3.1 that will allow you to get to the desired result.

            Stay tuned!




            • Re: How to get the value of a variable with a widget?

              @Stefan: Thank you for your response! I am looking forward to the new version of Qlik Sense.


              Such a widget can also be developed using Qlik Sense 3.0. I developed the widget using the following method.

              To set the value of a variable, use a html button with ng-click="app.variable.setContent('MYVAR','1');".

              To get the value of a variable, create an input field in the properties (e.g. named myvar) of the widget and type there =$(MYVAR). You can use this value by referencing settings.myvar.

              This works if the variable has a nummeric value.


              Here is an example:



                <select ng-model="selectVal" ng-init="opt=settings.selVarValue" ng-change="app.variable.setContent(settings.selVarName, selectVal);" class="lui-select">


                 <option ng-selected="opt==1" value="1">{{settings.optLabel1}}</option>

                 <option ng-selected="opt==2" value="2">{{settings.optLabel2}}</option>

                 <option ng-selected="opt==3" value="3">{{settings.optLabel3}}</option>