Search code examples
pentahopentaho-cde

How to show a report with dynamic parameters from a chart on Pentaho?


I have a pie chart on my dashboard, using click action, I menaged to show a report that has one fixed parameter. Here is my JS function on click action:

 function showreport(scene) {
        var newWindow;
        if(scene.getCategory()=='POS'){
            newWindow=window.open("url_report?type_lm=POS", 'REPORT');
        }else{
            newWindow=window.open("url_report?type_lm=NEG", 'REPORT');
        }
    } 

This one works fine. But now I want to pass a dynamic parameter too ( the variable obtained with query component, it is stocked in result var (code_lm): Here is what I did:

function showreport(scene) {
    var newWindow;
    var code_lm=this.dashboard.getParameterValue('code_lm');
    if(scene.getCategory()=='POS'){
        newWindow=window.open("url_report?type_lm=POS&code="+code_lm, 'REPORT');
    }else{
        newWindow=window.open("url_report?type_lm=NEG&code="+code_lm, 'REPORT');
    }
} 

This one doesn't work, nothing is displayed by clicking the chart. I found this line var code_lm=this.dashboard.getParameterValue('code_lm'); causes the prob.

However, I do the same thing with button component :

function showreport() {
    var code_lm=this.dashboard.getParameterValue('code_lm');
    var newWindow =  window.open("url_report?code=" + code_lm,'REPORT');
} 

and it works perfectly so I wonder why this.dashboard.getParameterValue() is not working in some cases.

Can anyone tell me where comes from the problem ?


Solution

  • yes, if you want to pass value of parameter from query component then you need set parameter value by writing bellow code in post fetch of query component.

     function fun(code_lm) { 
    dashboard.setParam('yourParamName',code_lm.resultset);
    } 
    

    check out this may help you. How to pass a variable obtained from query component into a query on Pentaho CDE? may help you.