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: 
marco_puccetti
Partner - Creator
Partner - Creator

Mashup getContent function

Hello, i need to get, from a mashup web application, a variable content.

This variable is computed in this form:

Date(Date(Max([Data Decorrenza]) + 1)  + (0 - Sum([Importo Lordo Rata]))/Money(Round(Sum([Importo Lordo Rata]) / Round(max([Data Decorrenza]) - min([Data Decorrenza])))))

the problem is that using the app.variable.getContent, the result is the above expression and not the date value i expect.

Anybody knows how to get the computed variable content?

Thanks

Marco

16 Replies
reddy-s
Master II
Master II

Hi Macro Puccetti,

Based on the explanation you have given, looks the you have declared a variable with the above expression.

When you use app.variable.getContent ,it it will only return the string value like it has done. For you to get the expression valuated, create a hypercube with one measure and pass the string value from  app.variable.getContent to the hypercube and this gives you the calculated values of the expression.

If its just a dimension try using the field list instead of a hypercube.

Hope this is helpful.

Regards,

Sangram Reddy.

marco_puccetti
Partner - Creator
Partner - Creator
Author

But i need to populate an html input field with the computed variable, so which api have i to use?

Can you make me an example?

Another thing on Qliksense when i use the Let statement to set the variables values i've noticed the content of the variable is blank how can be? I need this content into the mashup application.

Thanks

Marco

reddy-s
Master II
Master II

Hi Marco Puccetti,

Here is what you need.

Firstly declare a variable in your script like this:

SC3.PNG

Then Create an input box(Or any other element you would like to bind the output to):

SC2.PNG

Create a hypercube by reffering to your variable:

SC1.PNG

Update the field in the UI in the function as done above.

You should see the Input field update after the function is updated

S4.PNG

Hope this helps.

Thanks and Regards,

Sangram Reddy.

marco_puccetti
Partner - Creator
Partner - Creator
Author

Ok, but i also need an onClick function that allows me to update an input text with a computed variable depending on the first input text variable. Is it possible?

Immagine.png

Thanks

Marco

reddy-s
Master II
Master II

Hi Marco,

As this would be a selection,

Just simply use the below code to trigger a selection inside the previous code :

function(reply){

//....... Your code from after you fetch the data from the hyper cube.

$("#buttonId").click(function() {

            app.field("[<Name of the field>]").selectMatch(<Value of the input field>, false);

        });

}

This code triggers a selection and hence re-generates the hypercube with the filtered result.

- Sangram Reddy

marco_puccetti
Partner - Creator
Partner - Creator
Author

I have created on qliksense an input text in which i have printed a variable value, so what have i to use to get that field content if i don't know exactly it?

I have tried the selectAll method but i don't find the prototype.

Thanks

Marco

reddy-s
Master II
Master II

Hi Marco,

Make sure your input box has an ID assigned and then use the below code to fetch the value you have in an input field.

$('#ID').val()


- Sangram

marco_puccetti
Partner - Creator
Partner - Creator
Author

I mean that on Qliksense i have a text field containing a variable value, so i need to get that value in a mashup application within an input file (as showed in the above posts).

Below the screen. How can i obtain what i desire?

Immagine.png

Immagine1.png

Thanks

Marco

reddy-s
Master II
Master II

Hi Marco,

Ok, So when you input a value into "importo Previsione" field in your mash up, the value in the text field in Qliksense which uses $(m_data_fine_previsione) variable has to be returned. Am I right?

If so,

just replace  "qDef": "$(VALUE_Y)" with "qDef": "$(m_data_fine_previsione)".

Now when you click on the "Raggiungibile il" button call this:

$("#buttonId").click(function() {

            app.field("[<Name of the field>]").selectMatch(<Value of the input field>, false);

        });


Doing this the hypercube gets the respective value for the value provided in the text field in Qliksense by executing the $(m_data_fine_previsione) expression.


If you need the properties of any Qliksense object(As in your case , text of an element ), just make use of :


S1.PNG

S2.PNG

app.getObjectProperties("CFyDy").then(function(model){

  console.log(model);

    });

Where "app" = instance of the app in which the object exists in.

Here "CFyDF" is the object ID of the text element in Qliksense.

You can get the ID from the single object browser:

S3.PNG

Thanks and Regards,

Sangram Reddy.