16 Replies Latest reply: Oct 2, 2015 2:10 PM by Alexander Karlsson RSS

    Qlik Sense 2.1 Engine API; AddAlternateState method

    Alex Byrd

      Adding an alternate state to the document using the Qlik Engine API is pretty straight forward. I know the Alternate State exists and how one can use the alternate state in an expression using set analysis on the visualization objects.


      How do we apply the Alternate State to a field object to be used as a filter? If I can't apply an alternate state to a filter object, I can't use the filters within that Alternate state in the expression in my visualization objects.


      Do I use GetObject() and then SetProperties() using the qStateName: parameter set from the AddAlternateState method?


      Any help?





      Resources for others:


        • Re: Qlik Sense 2.1 Engine API; AddAlternateState method
          Alexander Karlsson

          Hey Alex,


          Here is a sample using qsocks that will add a alternate state, then patch a list object to use that new state.


          var qsocks = require('qsocks')
          qsocks.Connect({appname: 'Sales Discovery.qvf'}).
          then(function(global) {
            return global.openDoc('Sales Discovery.qvf')
          .then(function(app) {
            app.addAlternateState('MyNewState').then(function() { 
                 return app.getObject('QEECN').then(function(object) {
                      return object.applyPatches([{
                           "qPath": '/qListObjectDef/qStateName',
                           "qOp": 'add',
                           "qValue": '"MyNewState"'
            .then(function() {


          Or as a Gist if the syntax highlighting is a bit annoying here




          This is the end result, top Listbox is now in its own state