2 Replies Latest reply: Jul 20, 2012 8:08 PM by Lee Matthews RSS

    Problem loading include file with extension?

    Lee Matthews

      I am working on integrating an existing javascript based API into QlikView as an extension object. I have the code working fine in a HTML file. But after porting it to an extension object I am getting an error when it tries to instantiate the custom object within the API. For example, I am loading the API with the following LoadScript method:

       

      Qva.LoadScript("/QvAjaxZfc/QvsViewClient.aspx?public=only&name=Extensions/GRSurfacePlot/SurfacePlot.js", function(){});

       

      Then in a function later in the script.js I declare the object that should be defined within the include file above:

       

      try{

           var GRPlot = new SurfacePlot(document.getElementById(divName));

      }

      catch(err){

           alert(err.message);

      }

       

      The try,catch block results in a pop-up that says "SurfacePlot is not defined". This would seem to indicate either a problem with the loading of the include file or that the code in the include file is not correct. The same code works fine when in a HTML file, so I assume it is the loading of the include file that is the problem. But how can I determine whether or not QlikView encountered an error in loading the include file via the Qva.LoadScript method?

        • Re: Problem loading include file with extension?
          Nicole Smith

          I'm not positive if this matters or not, but I always put the Qva.LoadScript brackets around my entire extension.  Have you tried putting the try/catch inside of them?  (See below for what I mean.)

           

          Qva.LoadScript("/QvAjaxZfc/QvsViewClient.aspx?public=only&name=Extensions/GRSurfacePlot/SurfacePlot.js", function(){

               Qva.AddExtension('GRSurfacePlot', function () {

           

                         //Some script here....

           

                         try{

                              var GRPlot = new SurfacePlot(document.getElementById(divName));

                         }

                         catch(err){

                              alert(err.message);

                         }

           

                         //Some more script here...

               });

           

          });