Qlik sense enigma.js and Engine API – CreateSessionObject list Measures

The enigma.js function createSessionObject is used to create a list object. The definition of what the list object should contain is defined by a json structure and is passed as a parameter. This json structure varies depends on what you want to fetch. 

Below is the definition to get the list of measures from an app

{
"qInfo": {
"qType": "MeasureList",
"qId": ""
},
"qMeasureListDef": {
"qType": "measure",
"qData": {
"title": "/qMetaDef/title",
"tags": "/qMetaDef/tags"
}
}
}

Example

qSession=enigma.create(config);
qSession.open().then((global) => {
qGlobal=global;

qGlobal.openDoc(app_id).then((app) => {
currApp=app;
currApp.createSessionObject(qParam).then(function(qObject){
console.log("created object");
qObject.getLayout().then(function(qProp){
res.json({msg:qProp.qMeasureList.qItems})
}, 
(e)=> {console.log(err);res.json(err)}); 

}
,(err)=>{ console.log(err);res.json(err)}) ;
})
},(err)=>{ console.log(err);res.json(err)})

 

Read blog post Qlik sense Enigmajs Create, Open session and list apps for more details on creating a session. For the complete list of enigma.j example follow the Qlik sense Enigma.js Example Series posts