1 Reply Latest reply: Mar 30, 2017 10:47 AM by Jonas Hörström RSS

    How to get a fields numerical values

    Marco Hamacher

      In a mashup I created I need the numerical field values for selection handling in js.

      I am able to access a fields data via the getData() method. When inspecting the returned object I can find the qNum and qText values in the .rows element, but unfortunately I can not access them.

      Is it possible to get these values via getData() or is there another way?

       

      In particular I am interested in a dates numerical representation.

        • Re: How to get a fields numerical values
          Jonas Hörström

          Guessing your issue here a little bit so bear with me.

           

          When you write that you can't access them do you know if they are available when calling upon them? The getData() method will return them when a notification of OnData has been triggered

          getData method ‒ Qlik Sense

           

          So to ensure that you get valid data you need to bind a listener on OnData the field. Example:

           

          var data = qlikApp.field("the-field").getData();
          data.OnData.bind(
            function(){
                 var len = data.rows.length;
                 for (var i = 0; i < len; i++){
                      console.log(data.rows[i].qNum);
                      console.log(data.rows[i].qText);
                 }
            });