2 Replies Latest reply: Aug 18, 2017 2:20 AM by Erik Wetterberg RSS

    Is getList executed multiple times?

    Marco Hamacher

      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"];






      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.




        • Re: Is getList executed multiple times?
          Francis Kabinoff

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

          • Re: Is getList executed multiple times?
            Erik Wetterberg

            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