Noa Elharrar
Noa Elharrar

Reputation: 1

Qlik Sense extension Backend Api undefined

I'm trying to develop an extension for Qlik Sense. I would want to use the Backend API but I get the following error:

Uncaught TypeError: Cannot read property 'selectValues' of undefined

node.on("click", function(d){
    this.backendApi.selectValues(0,[1,2],true);
});

Where's my mistake?

Thank you!

Upvotes: 0

Views: 227

Answers (1)

Stefan Stoychev
Stefan Stoychev

Reputation: 5012

In your case this will be executed in the context of the html element (node) and the html element dont have backendApi method. So the error is "correct"

Somewhere in your code (above this part of the code) you can define new variable that is the real Qlik context. And then use it inside the click event. Something like this:

paint: function ($element, layout) {
  var qlikContext = this;

  // ... more code here eventually

  node.on("click", function(d){
    qlikContext.backendApi.selectValues(0,[1,2],true);
  });
}

Upvotes: 1

Related Questions