Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

MVP
MVP

Backend Api getSelections

Hi,

is there any method to get the current selections of the app?

- Ralf

Tags (2)
1 Solution

Accepted Solutions
Not applicable

Re: Backend Api getSelections

Yes,

You can retrieve it with the getList method see https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/Workbench/Content/BuildingWebsi... for more information

10 Replies
Not applicable

Re: Backend Api getSelections

Yes,

You can retrieve it with the getList method see https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/Workbench/Content/BuildingWebsi... for more information

MVP
MVP

Re: Backend Api getSelections

Is there another way to get the result during the paint function? It seems to be the callback is made asynchronously, receives result after end of paint..

Not applicable

Re: Backend Api getSelections

Hi, I had the same question and i found a solution.

in the javascript file, you have to include "qlik" in define function, then you can call to app using this method:

var app = qlik.currApp();

code will be like this:

define(["jquery","qlik"], function($, qlik) {

return {

           paint : function($element, layout) {

                 var app = qlik.currApp();

                 app.getList("CurrentSelections", function(data){

                   console.log(data);

                 });

}

}

MVP
MVP

Re: Backend Api getSelections

That's exactly what I've coded but callback function is called after paint!

Not applicable

Re: Backend Api getSelections

Yes, it is asynchronously, so, if it needs to paint something when the selected fields are ready, the logic to render HTML should be inside of callback function.

   app.getList("CurrentSelections", function(data){

                  rendeView(); // for example

                 });

MVP
MVP

Re: Backend Api getSelections

Understand, but why the paint function isn't called after the selected fields are ready? Would make more sense..

Not applicable

Re: Backend Api getSelections

Essentially what you are doing is creating/accessing a separate object that gets its own change notifications. your extension will still fire a paint when the selection changes.

Not applicable

Re: Re: Backend Api getSelections

I used this to get the selected values during paint. You need to fetch all the entries in the field for it to work.

var selectedDates = qMatrix.filter(function(d) { return (d[0].qState == 'S') }).map(function(d) {

  return d[0].qNum

  });

MVP
MVP

Re: Re: Backend Api getSelections

Thanks, Karl. But this helps only for getting the selections inside of the defined cube. I don't understand why the API is lacking such basic function to obtain information about the current selections of the application.

Community Browser