Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello!
I'm beginner in qlik and I'm trying work with Qlick Sense 3.0 programmatically
I'm working with application described here
https://community.qlik.com/message/1114490#1114490
I have not enough experience with javascript and I need help with next code:
define( [
'qlik'
],
function (qlik) {
'use strict';
function run(){
console.log("START");
var app = qlik.currApp();
app.field('Year').selectValues([1997, 1998, 1999, 2000], true, true);
var selections = [];
app.getList("SelectionObject", function(reply){
console.log("APP.GETLIST");
$.each(reply.qSelectionObject.qSelections, function(key, value) {
console.log("$.EACH");
selections.push({'field':value.qField, 'selected':value.qSelected});
});
});
console.log("END");
return selections;
}
return {
paint: function ($element) {
var result = run();
console.log(result);
return qlik.Promise.resolve();
}
};
} );
Order of execution is: START --> END --> APP.GETLIST --> $.EACH
That is not right for me. And i do not understand why code execution has this order.
I want to code execution will has next order: START --> APP.GETLIST --> $.EACH --> END
What should I do for this?
I will appreciate for links, where I can read about it.
Thanks.
Possible Solution:
var app; // Global app
var appSelections;
define( [
'qlik'
],
function (qlik) {
'use strict';
function run(promise){
console.log("START");
app = qlik.currApp();
app.field('Year').selectValues([1997, 1998, 1999, 2000], true, true);
var loc_selections = [];
app.getList("SelectionObject", function(reply){
console.log("APP.GETLIST");
$.each(reply.qSelectionObject.qSelections, function(key, value) {
console.log("$.EACH");
loc_selections.push({'field':value.qField, 'selected':value.qSelected});
});
console.log("END");
promise.resolve(loc_selections);
});
console.log("RESULTS:");
appSelections = loc_selections;
console.log(appSelections);
}
return {
paint: function ($element) {
var result = run(qlik.Promise);
}
};
}
);
Possible Solution:
var app; // Global app
var appSelections;
define( [
'qlik'
],
function (qlik) {
'use strict';
function run(promise){
console.log("START");
app = qlik.currApp();
app.field('Year').selectValues([1997, 1998, 1999, 2000], true, true);
var loc_selections = [];
app.getList("SelectionObject", function(reply){
console.log("APP.GETLIST");
$.each(reply.qSelectionObject.qSelections, function(key, value) {
console.log("$.EACH");
loc_selections.push({'field':value.qField, 'selected':value.qSelected});
});
console.log("END");
promise.resolve(loc_selections);
});
console.log("RESULTS:");
appSelections = loc_selections;
console.log(appSelections);
}
return {
paint: function ($element) {
var result = run(qlik.Promise);
}
};
}
);