16 Replies Latest reply: Nov 17, 2015 9:11 AM by Marco Puccetti RSS

    Mashup getContent function

    Marco Puccetti

      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

        • Re: Mashup getContent function
          Sangram Reddy

          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.

            • Re: Mashup getContent function
              Marco Puccetti

              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

                • Re: Mashup getContent function
                  Sangram Reddy

                  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.

                    • Re: Mashup getContent function
                      Marco Puccetti

                      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

                        • Re: Mashup getContent function
                          Sangram Reddy

                          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

                  • Re: Mashup getContent function
                    Marco Puccetti

                    I have noticed that the setContent function works perfectly, while the getContent seems to not enter the callback function.

                    This is the statement:

                     

                    app.variable.getContent('$(variable_name)',function ( reply ) {

                      var sTemp = JSON.stringify( reply );

                      var json_parsed = JSON.parse(sTemp);

                      sTemp = json_parsed.qContent.qString;

                      $("#OBJ_ID").val(sTemp);

                      } ); 

                     

                    This statement is inserted into a javascript onClick routine.

                     

                    I expect to get the variable value, isn't it?

                     

                    Thanks

                    Marco

                    • Re: Mashup getContent function
                      Marco Puccetti

                      It seems that $(variable_name) within the getContent function doesn't work.

                      So how can i get a variable content using the getContent function for a variable of this type:

                       

                      SET variable =  Date($(date_1)  + $(date_2));

                       

                      Thanks

                      Marco