Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I would like to dynamically evaluate a string I got from a table in a Qlik Extension.
The story:
1. I retrieve a hypercube
2. In the hypercubematrix one column in a row contains a formula: e.g. =left('Qlik is Great',4)
I would like to have the formula evaluated in the extension at runtime.
3. The result should be a hypercube with the column evaluated: e.g. 'Qlik'
Which api do I need to use?
kr,
Dion
Hi Dion,
This is kind of tricky... You need to call app.evaluate to get this done. But this method is not available in the App API. Instead you need to use enigma.js. Since enigma is autogenerated, all methods defined in the engine API are available. Do note that enigma is flagged as experimental, though.
In an extension you can find enigma at this.backendApi.model.enigmaModel. That is a reference to the GenericObject wrapper, and in this case you need the app wrapper at this.backendApi.model.enigmaModel.app. This means you could do:
this.backendApi.model.enigmaModel.app.evaluate("1+1").then(function(reply){console.log("got reply",reply)});
And you will get a printout like this:
got reply 2
Hope this helps
Erik Wetterberg
Hi Dion,
This is kind of tricky... You need to call app.evaluate to get this done. But this method is not available in the App API. Instead you need to use enigma.js. Since enigma is autogenerated, all methods defined in the engine API are available. Do note that enigma is flagged as experimental, though.
In an extension you can find enigma at this.backendApi.model.enigmaModel. That is a reference to the GenericObject wrapper, and in this case you need the app wrapper at this.backendApi.model.enigmaModel.app. This means you could do:
this.backendApi.model.enigmaModel.app.evaluate("1+1").then(function(reply){console.log("got reply",reply)});
And you will get a printout like this:
got reply 2
Hope this helps
Erik Wetterberg
Hi,
you have to be carefull, the enigma is only available in newer versions of qlik sense and the path is changed.
In the newest qlik release this is move from .enigmaModel direct to .model
bye Konrad
What release are you refering to? In September 2017 it is still available at
this.backendApi.model.enigmaModel
Erik