Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

zadravecm
New Contributor III

Qlik Sense JS Extension createTable() does not return values

Hi,

I have some trouble with creating table in Qlik Sense extension.

If I wrote:

let object = app.createTable(dimensions,{rows:1000});

console.log('object: ', object);

Promise.all([object]).then(function(values){

       console.log('rows: ', object.rows);

       console.log('qHyperCube: ', object.qHyperCube);

});


I get

Screen Shot 2018-01-26 at 08.13.05.png


Witch I don't understand:


- we can see that when I print whole object I can see rows (and they are right) and qHyperCube witch has same rows inside.

- But when I wan't to extract this information I get empty array/undefined object


- I understand that createTable only return promise,....


How do you do this?


Marko Zadravec

1 Solution

Accepted Solutions
ErikWetterberg
Honored Contributor

Re: Qlik Sense JS Extension createTable() does not return values

Hi,

You need to wait for the OnData event before the rows are actually available.

The fact that you see them in the console is because Chrome doesnt check inside the object until you click on the arrow, at which time the data will be available.

Hope this helps

Erik Wetterberg

4 Replies
ErikWetterberg
Honored Contributor

Re: Qlik Sense JS Extension createTable() does not return values

Hi,

You need to wait for the OnData event before the rows are actually available.

The fact that you see them in the console is because Chrome doesnt check inside the object until you click on the arrow, at which time the data will be available.

Hope this helps

Erik Wetterberg

zadravecm
New Contributor III

Re: Qlik Sense JS Extension createTable() does not return values

Yes this is true,

I figure out that I need to bind observer to table, to check when data come.

I don't know why, but Promise.all doesn't work.

ErikWetterberg
Honored Contributor

Re: Qlik Sense JS Extension createTable() does not return values

Promise.all does work, but the promise resolves when the table object is available, which is earlier than it has data, the framework needs to call getLayout to get the data.

Erik Wetterberg

sanket_raj
New Contributor II

Re: Qlik Sense JS Extension createTable() does not return values

How did you bind observer to table? I tried using below code but it is not working:

 

var table = qlik.table( this ); var listener = function() { var rowCount = table.rowCount; var colCount = table.colCount; table.OnData.unbind( listener ); //unregister the listener when no longer notification is needed. }; table.OnData.bind( listener ); //bind the listener