Skip to main content

Integration, Extension & APIs

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

Announcements
Welcome to Qlik Community! Check out our new navigation! FIND OUT MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
billgates
Creator
Creator

I can't programmatically get selections, please assist

Hello!

I'm absolutely new in this technologies and I'm trying work with Qlick Sense 3.0 programmatically.

I created application like on video from youtube:

https://www.youtube.com/watch?v=xT0KPWtrgMg

And now my purpose is to get/set selections programmatically.

To do this, I created extension and added it on sheet.

When sheet is updating, my method executing.

And my question is:

What should i do to get selected id or value in browser console?

What i made:

I've selected some fields:

h_1472559416_5877018_91274d26d6.png

And next, i'm wrote code:

define( [ "qlik"],

function ql(qlik) {

  function myFunction(){

  var app = qlik.openApp('Auto.qvf');

  app.getList('CurrentSelections', function(reply){

       console.log(reply);

  });

  }

  return {

  paint: function ($element) {

  myFunction();

  return qlik.Promise.resolve();

  }

  };

} );

But, in result, I'm always receiving an empty array.

h_1472559472_5247683_2ef779b35f.png

How to do it right?

Please Assist.

Yes, i read topics before create new.

Thanks.

1 Solution

Accepted Solutions
TKendrick20
Partner - Specialist
Partner - Specialist

You can probably use var app = qlik.CurrApp(); instead of specifying the app name to start if this is an embedded extension object. Then, I referred to this documentation: Current selections ‒ Qlik Sense‌. But I can't seem to get it to work... let me know if you have any luck instituting the foreach.

var currentSelection = App.GetCurrentSelection();

foreach (var selectedField in currentSelection.selections) {

     alert("Field: " + selectedField.Field);

     alert("Selected values : " + selectedField.Selected);

}

View solution in original post

4 Replies
TKendrick20
Partner - Specialist
Partner - Specialist

You can probably use var app = qlik.CurrApp(); instead of specifying the app name to start if this is an embedded extension object. Then, I referred to this documentation: Current selections ‒ Qlik Sense‌. But I can't seem to get it to work... let me know if you have any luck instituting the foreach.

var currentSelection = App.GetCurrentSelection();

foreach (var selectedField in currentSelection.selections) {

     alert("Field: " + selectedField.Field);

     alert("Selected values : " + selectedField.Selected);

}

billgates
Creator
Creator
Author

Thanks, Tim!

Looks like solution found.

I will wrte solution after tests

billgates
Creator
Creator
Author

It Works!

h_1472569178_8181237_e32e379d7f.png

define( [

  'qlik'

],

function (qlik) {

  function myFunction(){

  var app = qlik.currApp();

  app.getList("SelectionObject", function(reply){

  // console.log(reply);

  var str = "";

  $.each(reply.qSelectionObject.qSelections, function(key, value) {

  console.log(value.qSelected);

  });

  });

  }

  return {

    paint: function ($element) {

  myFunction();

  return qlik.Promise.resolve();

  }

  };

} );

___

Teis, thanks for pm


oknotsen
Master III
Master III

If your question is now answered, please flag the Correct Answer (via the big "Correct Answer" button near every post) and Helpful Answers (found under the Actions menu under every post).

If not, please make clear what part of this topic you still need help with .

May you live in interesting times!