0

I want to display a data (in my case, a String) by using Query component on Pentaho CDE. However, nothing is displayed.

Here is what I did:

On DataSource Panel:

enter image description here

The query is

select city_name from tb_city where city_id='1';

and it gives 'NYC' as result.

Then On Component Panel - Query Component:

enter image description here

With a JS function on Post Execution:

function f() {
document.getElementById('header_c').innerHTML =myresult; }

where header_c is the name of the column where I want to display the query result.

I think there's no prob with this function and other stuffs because when I change myresult to any string like 'HELLO' in the function, it's displayed.

Does anyone have an idea where's wrong? I verified and the query has no prob.

1 Answers1

1

write this code in your post fetch. where abc is Result Var

function fun(abc) { 
document.getElementById('qq1').innerHTML =abc.resultset;
} 
Primit
  • 825
  • 7
  • 13
  • Oh perfect! Thanks so much! –  Aug 22 '19 at 10:05
  • By the way, I want to use this variable in my query in Datasources, like "select * from table where city_m=${myresult}", however it is not working. Any idea? –  Aug 22 '19 at 10:07
  • if the you want to pass parameter in datasource of other component then you can manually set it like write this line dashboad.setParam('paramName',abc.resultset) in above function. – Primit Aug 22 '19 at 10:12
  • Alright, here is what I did : function fun(abc) { document.getElementById('qq1').innerHTML =abc.resultset; Dashboard.setParameter('city_m_param',abc.resultset); } and in my query "select * from table where city_m=${city_m_param}. This query is used to display a barchart but since I've changed to it, it's not beeing displayed. Do I have to do extra things? –  Aug 22 '19 at 14:17
  • I made an another post to explain this problem, it would be nice if you can have a look! https://stackoverflow.com/questions/57611878/how-to-pass-a-variable-obtained-from-query-component-into-a-query-on-pentaho-cde –  Aug 22 '19 at 14:41