6 Replies Latest reply: Dec 15, 2014 7:14 AM by Erik Wetterberg RSS

    API CreateList strangeness (unexplained behaviour)



      I have some code to get specific field information in an extension:


          "qDef": {
              "qFieldDefs": ['Country']
          "qInitialDataFetch": [{
              qTop: 0,
              qLeft: 0,
              qHeight: 500,
              qWidth: 1
      }, function(reply) {


      The reply contains a qListObject.qDataPages[0].qMatrix property and I can loop through this to get the fields ('Germany', 'France', 'Sweden' etc).


      Elsewhere in code, I make the same call for the same field (country), but rather than getting back the fields, I don't get the qListObject property, and the qFieldList property contains the 2 fields that are available in the app:


      1. permissions: (...)
      2. get permissions: function (){return a&&(d===!0&&c(a.create||f,e),b(a.privileges||a.qMeta&&a.qMeta.privileges||[],e)),e}
      3. qFieldList: Object
        1. qItems: Array[2]
          1. 0: Object
          2. 1: Object
          3. lastElement: (...)
          4. length: 2
          5. __proto__: Array[0]
        2. __proto__: Object
      4. qInfo: Object
      5. qSelectionInfo: Object
      6. __proto__: Object

      This doesn't seem to make any sense - make the same call, and you should get the same data back, shouldn't you?  The only difference is that the second call uses an 'app' reference returned from an openApp(...) call, but I don't see why this would cause the issue.



        • Re: API CreateList strangeness (unexplained behaviour)
          Erik Wetterberg

          You should get the qFieldList if you call app.getList('Field',callback);


          If possible you should avoid calling getList, createList in an extension, they are meant for mashups. In most cases it is better to define your lists in initial properties.


          If you do call them, make sure you do not create a new list every time the paint() method is called.

            • Re: API CreateList strangeness (unexplained behaviour)

              Thanks for your reply.  I definitely get those two different responses for the same call.


              I am using the 'mashups' API because I need to call 'openApp' and work with 'app level' objects that are 'outside' of the scope of the extension.  I can find no mention in the docs that getList and createList should be avoided if possible in an extensions context - is this for performance reasons?


              Also, I'm not using a 'paint' function; I'm using Angular with a template and some $scope level functions to call code.

                • Re: API CreateList strangeness (unexplained behaviour)
                  Erik Wetterberg

                  Hi Shane,

                  If you are working with another app you will need to use the Mashup API calls, initialProperties will only work with the current app.


                  The problem with using the createCube, createList, getList etc calls from within an extension is that they will create a session object every time they are called. The paint() method is called on all changes that affects the visualization, so that means a lot of calls, more than most people think. The same goes for the angular approach: angular might call your method more times than you think, so you will end up with many session objects.


                  Also the mashup API sets up a subscription, so the callback you provide might be called several times, which maybe is not what you expected.


                  Hope this helps



                    • Re: API CreateList strangeness (unexplained behaviour)

                      Hi Erik,


                      thanks for the info about initialProperties - the other issue is that the calls I'll be making are based on the current selections in the current app (I then get field information about the other app).


                      Are there any guidelines for calling those API methods? Calling things needlessly is never a good idea, but what techniques can Sense developers employ to improve performance and reduce session creation?


                      Thanks, Shane.

                        • Re: API CreateList strangeness (unexplained behaviour)
                          Erik Wetterberg

                          Well you need to keep track of your open apps and created objects. In chrome developer tools you can easily see your created web sockets (every open app has its own web socket). You can also set breakpoints in your callback functions and verify that they are called the way you expect.

                            • Re: API CreateList strangeness (unexplained behaviour)
                              Erik Wetterberg

                              Did some troubleshooting on this and it seems like this is a bug. It happens if you open the same app from your mashup several time, like this:


                              var app = qlik.openApp('A');
                              var app2 = qlik.openApp('A');
                              app.createList(...); //this wont work, you will get the data from your first createList call again


                              This affects all calls that creates generic (session) objects, so getList, createList, createCube, createGenericObject, getAppObjectList.