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: 
Anonymous
Not applicable

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
Francis_Kabinoff
Former Employee
Former Employee

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
Francis_Kabinoff
Former Employee
Former Employee

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

ErikWetterberg

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