Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
mrchmchr
New Contributor III

Is getList executed multiple times?

Hi everyone,

I stumbled upon a problem in my code.

app.getList('CurrentSelections', function(reply) {

                  console.log("this line and the next 3 are executed to often");

                  selectedField = reply.qSelectionObject.qSelections.map(function(item) {

                    return item["qField"];

                  });                 

                }).then(

                  function(){...}

               );

Somehow the code in the callback is evaluated multiple times, even though the code executed after the promise is returned is only executed once.
Maybe there is something happening when requesting a List that I am not aware of.

I am glad for any insights.

Thanks,

Marco

1 Solution

Accepted Solutions
Employee
Employee

Re: Is getList executed multiple times?

This is working as intended. The callback will be called every time selections are made, the promise will return just once.

View solution in original post

2 Replies
Employee
Employee

Re: Is getList executed multiple times?

This is working as intended. The callback will be called every time selections are made, the promise will return just once.

View solution in original post

ErikWetterberg
Honored Contributor

Re: Is getList executed multiple times?

Hi Marco,

Just to add to Francis answer there is an additional problem if you do this in the paint method in an extension (which is in most cases not a good idea) it will be executed multiple times. All the callbacks in the API are subscriptions, they will be called whenever the data requested changes, which in the case of CurrentSelections will be a lot of times.

If you use the promise it will only be resolved once, and that will be when the object is created, which in most cases means that data is not available yet. You then need to listen to the Validated event to get the actual data.

Hope this helps

Erik Wetterberg