Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rbecher
MVP
MVP

Backend Api getSelections

Hi,

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

- Ralf

Astrato.io Head of R&D
1 Solution

Accepted Solutions
Not applicable

10 Replies
Not applicable

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

rbecher
MVP
MVP
Author

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..

Astrato.io Head of R&D
Not applicable

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);

                 });

}

}

rbecher
MVP
MVP
Author

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

Astrato.io Head of R&D
Not applicable

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

                 });

rbecher
MVP
MVP
Author

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

Astrato.io Head of R&D
Not applicable

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

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

  });

rbecher
MVP
MVP
Author

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.

Astrato.io Head of R&D