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

Field API

Hi

I try to use QlikSense Field API like this: select method ‒ Qlik Sense

This is my  code:

Unbenannt.PNG

And this is the result in Development Console:

Unbenannt.PNG

The Problem is I can't  get acces to the rows Array.

It is undefined, in row 251.

If I print "console.log( fields.rows)" I get this:

Unbenannt.PNG

How can I get acces to the Array?

The length is 0, seem like an error to me

1 Solution

Accepted Solutions
bgk
Employee
Employee

Hello,

You are most probably trying to access the data before it is available to you. The developer console provides this data when it is available giving you the possibility to drill down and investigate each row which can seem confusing sometimes. In the code you need to bind the field to a listener and work with the data when it has arrived. E.g.

var data = qlikApp.field("the-field").getData();

console.log(data); // Will show the data in develop console with rows its length etc

console.log(data.rows.length); // will most probably show 0 since the data hasn't arrived yet

data.OnData.bind( 

  function(){ 

       var len = data.rows.length; 

       console.log(len); // will show the real size of rows since the data is available

       for (var i = 0; i < len; i++){ 

            console.log(data.rows.qText + data.rows.qState);  // State flag (is the data selected or not)

       } 

  }); 

Hope it helps.

View solution in original post

2 Replies
bgk
Employee
Employee

Hello,

You are most probably trying to access the data before it is available to you. The developer console provides this data when it is available giving you the possibility to drill down and investigate each row which can seem confusing sometimes. In the code you need to bind the field to a listener and work with the data when it has arrived. E.g.

var data = qlikApp.field("the-field").getData();

console.log(data); // Will show the data in develop console with rows its length etc

console.log(data.rows.length); // will most probably show 0 since the data hasn't arrived yet

data.OnData.bind( 

  function(){ 

       var len = data.rows.length; 

       console.log(len); // will show the real size of rows since the data is available

       for (var i = 0; i < len; i++){ 

            console.log(data.rows.qText + data.rows.qState);  // State flag (is the data selected or not)

       } 

  }); 

Hope it helps.

satyaprakash
Partner - Contributor III
Partner - Contributor III

Hi,

I am using this api in mashup.

Sometimes rows length is coming 0 even after binding and sometimes (with actual length ) it works.

Any solution for this?

Satya