Pentaho

 View Only

 Query component with dynamic datasource

  • Pentaho
  • Ctools
  • Pentaho
Andy Rathbone's profile image
Andy Rathbone posted 08-05-2019 14:23

Hi,

We have recently upgraded from version 5.0.4 to 8.2 and one of my functions has stopped working.

In the older version I could run the below code in the pre exec and pass a value into the dataAccessId so it would run that query. 

But, in the new version, it looks like it is setting the values before running the pre exec.  The fist time the code runs it uses the default query.  But if I run it again, it uses the query that was passed the first time.

function (){

var d = this;

//Get query name

var qry = getFirstPart(p_runcsv, '|'); var path = d.dashboard.context.path; path = path.replace('wcdf', 'cda'); d.queryDefinition.dataAccessId = qry; d.queryDefinition.path = path; }

I hope that makes sense.  Any help would be hugely appreciated.


#Pentaho
#Ctools
Joana Carvalho's profile image
Joana Carvalho

Hi Andy,

if you want to change dynamically the datasource, you just need to put on the Pre Exec the following code:

function (){

var d = this;

//Get query name

var qry = getFirstPart(p_runcsv, '|');

d.queryDefinition.dataSource = qry;

}

qry needs to be the name of the query that is defined on the datasources panel.

Thanks,

Joana