Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
StefanBackstrand
Partner - Specialist
Partner - Specialist

Validating expression in Capabilities API

Is there a way in the Capabilities API to evaluate a custom expression in an app, and just get the result of that expression back?

Or is enigma.js with JWT's needed for this?

Like, if I want to get the value back from an expression like "=sum(num_of_something)", without having that in an existing KPI object, and not create a KPI object on the fly.

Labels (1)
  • API

1 Solution

Accepted Solutions
hakana
Employee
Employee

Loooong time since I worked with the client but I think you can do something like:

app = await window.engineModuleGlobal.getCurrentApp()
result = await app.evaluateEx({"qExpression": "1+1"});

{
"qvalue": {
"qText": "2",
"qIsNumeric": true,
"qNumber": 2
}
}

 

View solution in original post

4 Replies
hakana
Employee
Employee

It should be possible with enigma.js at least (or Qlik CLI)
https://qlik.dev/apis/json-rpc/qix/doc#%23%2Fentries%2FDoc%2Fentries%2FEvaluateEx

 

StefanBackstrand
Partner - Specialist
Partner - Specialist
Author

Yes, but that will require either a JWT or setting up an API key or ticketing - right?

I would like to do it in the context of Capabilities API, where the users is already authenticated.

hakana
Employee
Employee

Loooong time since I worked with the client but I think you can do something like:

app = await window.engineModuleGlobal.getCurrentApp()
result = await app.evaluateEx({"qExpression": "1+1"});

{
"qvalue": {
"qText": "2",
"qIsNumeric": true,
"qNumber": 2
}
}

 

alex_colombo
Employee
Employee

Hi @StefanBackstrand , you can do this with Capability APIs method createGeneric object, see this link for an example.

Regarding Engine APIs (used by enigma.js), you can access them from Capability APIs all the time. You just need to access the enigmaModel object present in app objected return by openApp method.

You have to first wait for enigmaModel promise, then acces enigmaModel and use any of the Engine APIs method. Below an example using createSessionObject method.
 

await qlikApp.model.waitForOpen.promise;

const appProsObj = await qlikApp.model.enigmaModel.createSessionObject(objectDef);