5 Replies Latest reply: May 2, 2016 3:17 AM by Erik Wetterberg RSS

    Catching Mashup Events

    Darius Pranskus

      Hi

       

      I created a QlikSense mashup using API & JS. WHat I want is to catch an event when user selects something or clears selections and then store active selections in session.

       

      Could somebody point me to right direction how to catch that event. I suppose it is some JS code. Thanks

        • Re: Catching Mashup Events
          Stefan Walther

          Hi d.pranskus,

           

          thx for asking. Unfortunately we haven't exposed events in general publicly nor documented it. But I definitely acknowledge, that this is something we should look into ...

          So cannot promise anything, but ... ;-)

           

          Regards

          Stefan

          • Re: Catching Mashup Events
            Erik Wetterberg

            Hi Darius,

            You can use app.getList('SelectionObject', callback).

            Documentation is here:

            https://help.qlik.com/en-US/sense-developer/2.2/Subsystems/APIs/Content/MashupAPI/Methods/getList-method.htm 

             

            Your callback function will be called whenever selections change. A small example:

            function FieldList(app) {
               var me = this;
              app.getList("FieldList", function(reply) {
               me.fields = reply.qFieldList.qItems;
               me.render();
              });
              app.getList('SelectionObject', function(reply) {
              $("[data-qcmd='back']").parent().toggleClass('disabled', reply.qSelectionObject.qBackCount < 1);
              $("[data-qcmd='forward']").parent().toggleClass('disabled', reply.qSelectionObject.qForwardCount < 1);
               me.selections = reply.qSelectionObject.qSelections;
               me.render();
              });
            }
            
            FieldList.prototype.render = function() {
               var $fields = $("#fields"), str = "<ul class='list-group'>", added = {}, me = this;
               if(this.selections) {
               this.selections.forEach(function(fld) {
               str += '<li class="list-group-item" data-value="' + fld.qField + '">' + fld.qField + '<span class="badge">' + fld.qSelectedCount + '/' + fld.qTotal + '</span></li>';
               added[fld.qField] = true;
              });
              }
               if(this.fields) {
               this.fields.forEach(function(fld) {
               if(!added[fld.qName]) {
               str += '<li class="list-group-item" data-value="' + fld.qName + '">' + fld.qName + '</li>';
              }
              });
              }
               str += "</ul>";
               $fields.html(str);
            }
            
            
              • Re: Catching Mashup Events
                Sergio Gonzalez

                Hi Erik,

                I'm trying here something similar in a mashup. When I try your code and make some selection I get an error from engine that says: "15: Operation aborted".

                Documentation is no longer on the link you provided. Any idea what could be going on?

                Thank you!

                  • Re: Catching Mashup Events
                    Francis Kabinoff

                    Hey Sergio,

                     

                    Error code 15 is associated with an operation being aborted, and, in my experience, is usually associated with either making or clearing selections while the engine is still performing another task which the engine has to run again when selections change. It has never actually negatively effected my app, and as long as you are not experiencing any unexpected behavior from it, which I'm assuming you're not, it's probably safe to ignore.

                    • Re: Catching Mashup Events
                      Erik Wetterberg

                      Hi Sergio,

                      The 'Operation aborted' happens when the user makes (or clears) a selection at the same time we are trying to fetch data. The client code should try again and get new data that reflects the new selection state. So this error is normal, I don't really know why we print it in the console, we probably shouldn't.

                       

                      I have updated the link, it should work now.

                       

                      Erik