Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nategreen
Contributor III
Contributor III

Programmatically exporting a specific table object in Qlik Sense app

I would like to automate the export of a qlik sense table object and was wondering if anyone has ideas of how to do this using powershell, api or another method. This table object currently takes too long to be processed via nprinting and i'd like to avoid creating this table in script and storing to csv if there is another method to automate the exporting of the table.

Labels (3)
3 Replies
rubenmarin

Hi, the exportData method of the Table API could export as if you do the action to export on front-end, I've just make some test, but I haven't deployed anything in a productive environment.

So far I've just created a mashup template using dev hub and adding this code:

app.getObject('id_object_to_export').then(function(model) {
  var table = qlik.table(model);
  table.exportData({download: true});
})

And it downloads the object when you open the mashup.

nategreen
Contributor III
Contributor III
Author

Thanks for this suggestion. Can you walk me through a couple of the details. Is the 'id_object_to_export' the only parameter needed? Are you keeping the content of the mashup template and adding the getobject? this is what the .js script tab in the mashup looks like and I'm not getting the sample table to export.

/*
* Basic responsive mashup template
* @owner Enter you name here (xxx)
*/
/*
* Fill in host and port for Qlik engine
*/
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 --
//get objects -- inserted here --
app.getObject('DRNJdBP').then(function(model) {
var table = qlik.table(model);
table.exportData({download: true});
})
//create cubes and lists -- inserted here --

} );

rubenmarin

Hi, first you need to "open" the app:

//open apps -- inserted here --
var app = qlik.openApp('app_id', config);

Then you can use the getObject method of this app object.