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: 
JohnIssue
Contributor III
Contributor III

Is there any method for API to trigger a function when a variable changes its value in Qlik?

I am working on a mashup with Qlik sense. I wonder if there exists a method that allows me to execute an angular function everytime a Qlik variable changes its value. Or if anyone knows how can I do it. Thanks in advance!

Labels (5)
3 Replies
Øystein_Kolsrud
Employee
Employee

I think the simplest way is to open the variable, for instance using "GetVariableByName" and then listen for its change notifications:

https://help.qlik.com/en-US/sense-developer/November2022/Subsystems/EngineJSONAPI/Content/service-do...

JohnIssue
Contributor III
Contributor III
Author

As a first aproach I am using the method selectionState() with onData(). It seems to trigger the function if a variable changes its value. Is it normal? I did not expect this  and I do not know  if I am missing something.

 

I change the variable value with a bottom and this changes no value in any field.

 

thanks again!

Øystein_Kolsrud
Employee
Employee

I'm not familiar with the details of that API and how it translates into the engine API endpoint, so others might give better answer here. But I suspect that there are conditions where a variable could change where the selection state is not affected. An obvious case would be if the value of the variable is changed explicitly and not through a change in the app data or selection state. I'm therefore not sure the approach you describe here will be complete and capture all cases where the variable changes, but it all depends on your particular use case! I assume listening on the selection state change events should capture most of the cases, so it might certainly turn out to be sufficient in your case if the conditions are right.