Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Lee_Matthews
Former Employee
Former Employee

Problem loading include file with extension?

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?

1 Solution

Accepted Solutions
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...

     });

});

View solution in original post

2 Replies
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...

     });

});

Lee_Matthews
Former Employee
Former Employee
Author

Brilliant! Thanks Nicole. I had copied the structure from a previous extension I did. The previous extension worked fine, (which was in turn copied from one of the 'standard' extensions). But this one for some reason seemed to need each of the LoadScript statements (there are 4) wrapped within each other. That solved the problem.