Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
johannaalmm
Contributor II
Contributor II

Global variable or custom property to store value during extension paint function

Hello,

I'm new to building extensions and I'm wondering in what way it would be possible to store a value from an input field, so that when the extension is rendered by the paint function, the value won't be overwritten/reset. Meaning, in what way can I create a global variable that will not be reset once the paint function is called? Or if it is possible to declare a custom initialProperty that I can set and get in the paint function?

I've looked through some documentation but cannot seem to find a solution to my specific problem...

 

Any help would be greatly appreciated, and just let me know if further explanation is needed!

Labels (1)
1 Solution

Accepted Solutions
alex_colombo
Employee
Employee

Yes I'm referring to that.

More specifically, inside your extension code you can access to Engine API starting from qlik object:

  • First you have to wait for the promise from Engine API for understanding if Engine APIs are ready

 

await qlik.currApp().model.enigmaModel.waitForOpen

 

  • Then you can access all Engine APIs methods, for you scenario you can get your variables by ID or Name. For getting by name there is another method getVariableByName

 

await qlik.currApp().model.enigmaModel.getVariableById('_yourVariableId_')

 

  • Set a variable value as string (setStringValue) or number (setNumValue)

 

const variable = await qlik.currApp().model.enigmaModel.getVariableById('_yourVariableId_');
await variable.setStringValue('test')

 

 

You could use Capability APIs for doing the same thing (here the get content and here to set a content) but with Engine APIs will work for both Capability and nebula.js approach.

As reference below Engine APIs documentation for methods mentioned above

GetVariableById 

SetStringValue

View solution in original post

3 Replies
alex_colombo
Employee
Employee

You can use Qlik Sense variables for getting/setting values and then render variables' values into your extension input field.

For having a default value always rendered by your extension, create a variable in QlikSense with the default value and then render it into your input field.

You can use Engine API in extension code for getting/setting Qlik Sense variable values

johannaalmm
Contributor II
Contributor II
Author

alex_colombo
Employee
Employee

Yes I'm referring to that.

More specifically, inside your extension code you can access to Engine API starting from qlik object:

  • First you have to wait for the promise from Engine API for understanding if Engine APIs are ready

 

await qlik.currApp().model.enigmaModel.waitForOpen

 

  • Then you can access all Engine APIs methods, for you scenario you can get your variables by ID or Name. For getting by name there is another method getVariableByName

 

await qlik.currApp().model.enigmaModel.getVariableById('_yourVariableId_')

 

  • Set a variable value as string (setStringValue) or number (setNumValue)

 

const variable = await qlik.currApp().model.enigmaModel.getVariableById('_yourVariableId_');
await variable.setStringValue('test')

 

 

You could use Capability APIs for doing the same thing (here the get content and here to set a content) but with Engine APIs will work for both Capability and nebula.js approach.

As reference below Engine APIs documentation for methods mentioned above

GetVariableById 

SetStringValue