How to get the value assigned inside queryTask.executeForCount() to use elsewhere outside of it? In the following example, I want flag = 1 when count > 0. But when I access flag outside of queryTask.executeForCount(), the value is not changed.
Note: the code runs in Web AppBuilder Developer Edition.
...
var flag = 0;
queryTask.executeForCount(query, lang.hitch(this, function(count) {
if(count > 0) {
flag = 1; // Suppose this one fires instead of flag = 0
} else {
flag = 0;
}
}));
console.log(flag); // Still returns 0, I want it to return 1