Creating a connection using enigma.js

Enigma is Qlik's open-source promise wrapper for the engine. You can use enigma directly when you're in the Mashup API, or you can load it as a separate module. It's essential to also load the correct schema whenever you load enigma.js. The schema is a collection of the available API methods that can be utilized in each version of Qlik Sense. This means your schema needs to be in sync with your QS version.

When you are writing code from within the Mashup API, you can retrieve the correct schema directly from the list of available modules which are loaded together with qlik.js via 'autogenerated/qix/engine-api'.

The following example will connect to a Demo App using enigma.js and will retrieve a list of all available fields and write them out to the console:

define(function () {
return function () {
require(['qlik','enigma','autogenerated/qix/engine-api'], function (qlik, enigma, schema) {
//The base config with all details filled in
var config = {
schema: schema,
appId: "My Demo App.qvf",
session:{
host:"localhost",
port: 4848,
prefix: "",
unsecure: true,
},
}
//Now that we have a config, use that to connect to the //QIX service.
enigma.getService("qix" , config).then(function(qlik){
qlik.global.openApp(config.appId)
//Open App
qlik.global.openApp(config.appId).then(function(app){
//Create SessionObject for FieldList
app.createSessionObject( {
qFieldListDef: {
qShowSystem: false,
qShowHidden: false,
qShowSrcTables: true,
qShowSemantic: true,
qShowDerivedFields: true
}, qInfo: {
qId: "FieldList",
qType: "FieldList"
}
} ).then( function(list) {
return list.getLayout();
} ).then( function(listLayout) {
return listLayout.qFieldList.qItems;
} ).then( function(fieldItems) {
console.log(fieldItems)
} );
})
}
})}})
From enigma.js version 2.x onwards, getService('qix', config) has been replaced with the create(config) method. 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.116.51