8 Replies Latest reply: Nov 1, 2017 6:00 PM by Jason Robertson RSS

    Qlik Sense API Objects and Destroying

    Jason Robertson

      We have upgraded from QlikSense 3.1 to QlikSense June 2017 Patch 1 in our dev environment and one of the extensions we use is now failing in the newer version.  We are using a Show/Hide extension (GitHub - fadyheiba/ShowHide: This Qlik Sense extension is a container that shows or hides visualizations based on condit…) to toggle between showing two different charts on a sheet based on a drop down selection. The gist of what happens is for the currently selected chart the command

      $scope.app.getObject($element.find('div'), $scope.currentChart) is used. 

      When the toggle is used to select a different chart the following code is executed to destroy the currently created chart.

      function destroyObject() {

        return $scope.app.destroySessionObject($scope.currentChartModel.layout.qInfo.qId)

          .then(function() {return $scope.currentChartModel.close();})

          .then(function() {$scope.currentChartModel = null;});


      The getObject api is then called again with the correct id to get the new chart based on what was selected.  The problem begins when we try to toggle back to a chart that has already been displayed. An exception is thrown when the internal engine tries to set the layout for the control to display.

      TypeError: Cannot read property 'qType' of undefined

          at Object.f.setLayout (/resources/assets/client/client.js??1499952235400:69)

          at a.c [as fn] (/resources/assets/client/client.js??1499952235400:69)


      This is happening because the getLayout call (in the qlik js code) does not return the correct data. (Basically returns nothing).

      If I take the destroySessionObject call out everything appears to work as expected.

      I have also converted the code to use the visualization api instead. Using the close method of the QVisualization in place of the destroySessionObject and the app.visualization.get in place of getObject() and I see the same behavior.

      So is the call to destroy or close necessary?  (I cannot find any qlik documents stating you should always do this.)

      Does this sound like a potential bug in the new version or is this extension not doing things correctly? (I am new to qlik development)


      (There is also an example qvf at the above github address that will demonstrate the same behavior. The ShowHide: Buttoms sheet is a good example)

      Any help would be greatly appreciated.