Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik1_User1
Specialist
Specialist

Export data using API in mashup not working for container object

Hi All,

Need one help.

Can we export data from container object {container object has 3 tables in it} using mashup API? Currently I am not able to do so for 3 tables with in a container .

For a single objects below function is working like pie chart , single table or any chart that is not part of container object but not working for tables / or any other charts that are part of a container object.

Function used is 

exportdatas('chart1','wdmg')

//here wdmg is object id of container.


function exportdatas(divid,objectid){

app.getObject(divid,objectid).then(function(model){

var d = app.table(model);
d.exportData({'format':'CSV_C','state':'A','filename': 'exportdata.csv','download': true})

});

}

Please help on this.

Labels (4)
1 Solution

Accepted Solutions
alex_colombo
Employee
Employee

Hi @Qlik1_User1 , after you get the container object, you have to read which objects is containing. Then you have to perform a new getObject call pointing to the table you want to export. I usually use Engine APIs from Capability APis for doing this. Below an example:

//Wait Engine API promise
const promise = await app.model.waitForOpen.promise
//Get container object
const container = await app.model.enigmaModel.getObject('_yourContainerObjectId_');
//Get container layout for reading container children
const containerLayout = await container.getLayout();
//Get as an example the first children and then export its data (you should loop over children and do your stuff)
const chartOne = await app.model.enigmaModel.getObject(containerLayout.children[0].refId);
//Define export type as CSV
const exportDef = {
	"qFileType": "CSV_C",
	"qPath": "/qHyperCubeDef",
	"qExportState": 0,
	"qServeOnce": false
};
const exportData = await chartOne.exportData(exportDef);
//Print export url
console.log(exportData.qUrl)

 

View solution in original post

1 Reply
alex_colombo
Employee
Employee

Hi @Qlik1_User1 , after you get the container object, you have to read which objects is containing. Then you have to perform a new getObject call pointing to the table you want to export. I usually use Engine APIs from Capability APis for doing this. Below an example:

//Wait Engine API promise
const promise = await app.model.waitForOpen.promise
//Get container object
const container = await app.model.enigmaModel.getObject('_yourContainerObjectId_');
//Get container layout for reading container children
const containerLayout = await container.getLayout();
//Get as an example the first children and then export its data (you should loop over children and do your stuff)
const chartOne = await app.model.enigmaModel.getObject(containerLayout.children[0].refId);
//Define export type as CSV
const exportDef = {
	"qFileType": "CSV_C",
	"qPath": "/qHyperCubeDef",
	"qExportState": 0,
	"qServeOnce": false
};
const exportData = await chartOne.exportData(exportDef);
//Print export url
console.log(exportData.qUrl)