Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
JohanW
Partner - Contributor II
Partner - Contributor II

Qlik Sense exportImg not working?

I’m trying to export an image from a Qlik Sense mashup using the Visualization API ( viz.exportImg ).

It works but only for the very first app you open “AppA”, see example code below.

If you open another app ,”AppB”, before the first one the image export fails with error code: 2 (I have not found any documentation for what error code 2 means by the way).

If you however open the second app “AppB” after the first one “AppA” exporting images works but only ever for the first opened app. The “currApp” API call seems to follow this pattern, it only ever returns the first opened app.

Data export seems to work regardless of opening sequence.

Is this the expected behavior or is there a way to change the “active” app??

Example code:

var prefix = window.location.pathname.substr( 0, window.location.pathname.toLowerCase().lastIndexOf( "/extensions" ) + 1 );
var config = {
    host: window.location.hostname,
    prefix: prefix,
    port: window.location.port,
    isSecure: window.location.protocol === "https:"
};
require.config( {
    baseUrl: ( config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources"
} );

require( ["js/qlik"], function ( qlik ) {
    qlik.setOnError( function ( error ) {
        $( '#popupText' ).append( error.message + "<br>" );
        $( '#popup' ).fadeIn( 1000 );
    } );
    $( "#closePopup" ).click( function () {
        $( '#popup' ).hide();
    } );

    //callbacks -- inserted here --
    //open apps -- inserted here --
    
// var AppB = qlik.openApp('SimpleAppB.qvf', config); // If i comment this line in the export stops working??? Why???
 
    var AppA = qlik.openApp('SimpleAppA.qvf', config);
 
// var AppB = qlik.openApp('SimpleAppB.qvf', config); // Opening AppB here does not affect AppA export

    //get objects -- inserted here --
    AppA.getObject('QV01','Rwgz');

    var CurrApp = qlik.currApp(this);   // <- Allways returns the first opened app (see above)
    console.log('CurrApp is: ', CurrApp);

    var Imgsettings = { format: 'png', height: 300, width: 600 };
    var Datasettings = { format: 'OOXML', state: 'A' };

    AppA.visualization.get('Rwgz').then(function(vis){
        vis.exportImg(Imgsettings).then(
            function (success) {
            console.log('Image download link: ', success);
        }, function (error) {
            console.error('Image export error: ' , error);          
        });

        vis.exportData(Datasettings).then(
            function (success) {
            console.log('Data download link: ', success);
        }, function (error) {
            console.error('Data export error: ' , error);           
        });
     });
} );
Labels (4)
12 Replies
Aiham_Azmeh
Employee
Employee

Hi @will_br ,

That's unfortunate, this should have been fixed - please contact support and report the issue (so it get prioritised and eventually get in in future patches); meanwhile we will look into this.

will_br
Contributor III
Contributor III

That's ok @Aiham_Azmeh, thank you. A colleague reported the issue, hope it gets fixed soon.

briwilli
Contributor III
Contributor III

Five years later and this issue has not been resolved.  I am running into this same problem with my web based app.  The workaround I am using is to reload the entire web app, which is not ideal since it takes a while to reload all the Qlik javascript libraries