Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
thpessato
Contributor III
Contributor III

Hypercube callback after every selection

Hello all,

I'm creating a mashup using hypercube.

I'm trying to use a hypercube to get value 'Year', from a expression using the Qlik Engine. After that, I want to make an automatic selection on the field 'Year'.


So ok, my hypercube is working and calling my callback function. Then I set my selection on the right field. And it works.


But I realized that the callback function keeps getting called after every selection made on the mashup. Since my data doesn't change, I don't want it to happen. It's unecessary.

I managed this issue by:

1. Placing a flag like:

var hypercubeDone = false;

function callback(reply, app) {

        if(hypercube) {

              return;

          }

        // do some stuff

        hypercubeDone = true;
}

in my JavaScript file.

But that doesn't solve my problem of calling this method multiple times. So I tried another solution...

2. Destroying the hypercube after the call:

But don't know if this is a good practice. So I tried to find another way.

I don't want this to happen, since it is not necessary. Is there a right way to prevent this?

Thanks!!

15 Replies
paulcalvet
Partner - Specialist
Partner - Specialist

Thanks Erik,

I want to select the last month available when the user open the mashup.

I use the app.field function to do this :

app.field('Month').selectValues([11], false, true);

I try with this code, but it doesn't work...

app.createGenericObject( {

            fields: {

            qValueExpression:{"qExpr":"=max({$<[Year Month]={$(=maxstring([Year Month]))}>}Month)"}

            }                      

        }).then (function ( object ) {

            var str = object.fields;

            app.field('Month').selectValues([str], false, true);

            console.log(str);

        });

Thanks,

Paul

ErikWetterberg

Hi,

Try this:

app.model.enigmaModel.evaluate('max({$<[Year Month]={$(=maxstring([Year Month]))}>}Month)').then(function(reply){

     console.log("evaluated:",reply);

app.field('Month').selectValues([str], false, true);

});

Hope this helps

Erik Wetterberg

ErikWetterberg

Sorry, pretty difficult to edit those javascript snippet: it should of course say reply, not str in line 3. You also might need to convert string to number, not sure if the reply will be a string or number.

Hope this helps

Erik Wetterberg

paulcalvet
Partner - Specialist
Partner - Specialist

Ok, if I want to use app.model.enigmaModel.evaluate I need to load enigma.js before.

Is it possible to do this without enigma.js ?

Paul

paulcalvet
Partner - Specialist
Partner - Specialist

Erik,

I found the solution.

The value returned by the function is in Object.layout

app.createGenericObject( {

            year : {

                qValueExpression: "=max({$<[Year Month]={\"$(=maxstring([Year Month]))\"}>}Year)"

            },

            month: {

                qValueExpression: "=max({$<[Year Month]={\"$(=maxstring([Year Month]))\"}>}Month)"

            }

        }).then(function ( Object ) {

            app.field('Month').selectValues([Object.layout.month], false, true);

            app.field('Year').selectValues([Object.layout.year], false, true);

        });

Many thanks !!

Anonymous
Not applicable

Hi I am totally new to mashups, 
I have a business requirement where i am creating mashup from two different Apps( few objects from each app on single page ) and want selection from one app to be propagated to another without any CreateList function , more like qliksense does for a single app.
Is there any way to do that ?