0

I have a variable obtained by query component, I want to pass it to a query on Data sources that will be used by another query component, here is what I did:

1) DataSources - sql_company_id :

enter image description here

2) first Query Component :

enter image description here

With a JS function on Post Fetch:

function f(company_id) { 
    dashboard.setParam('company_id', company_id.resultset); 
} 

So company_id=1 in my example.

3) DataSources - sql_company_name

enter image description here

with parameter defined like below:

enter image description here

4) second Query Component :

enter image description here

with Post Fetch like this:

enter image description here

It is supposed to display the company name having company_id='1' but nothing appears.

When I change the second query to:

select company_name
from company
where company_id=1;

Then it works.

I'm not using correctly the variable {company_id} I suppose. I had a very similar prob and got the solution so I did in the same way this time. Where I got wrong?

  • add **company_id** in second query component's listener field. also set execution at start to **False** . did you define your parameter in **sql_company_name** datasource? check this https://stackoverflow.com/questions/57611878/how-to-pass-a-variable-obtained-from-query-component-into-a-query-on-pentaho-cde – Primit Aug 30 '19 at 04:04
  • yes, I defined the parameter company_id in sql_company_name datasource (screenshot under the query screenshot). How to add company_id to listener ? Because here, it's more selection of existing parameters. Should I make param_company_id (simple parameter) ? –  Aug 30 '19 at 07:46
  • you have to create simple parameter **company_id** if you haven't created yet. – Primit Aug 30 '19 at 07:52
  • okay, I created the simple parameter, set execution at start to false ( of the query component of company_name) but still not working. I must be missing out something important :( –  Aug 30 '19 at 07:57

0 Answers0