AnsweredAssumed Answered

Datasource scripting - parameter value always null

Question asked by Tiva Paferlonfeu on Jun 4, 2019

Hi all,

 

I'm evaluating Pentaho Reporting 8.2 and I'm facing a problem when I try to collect the value of a parameter in the "Global Scripting" of a JDBC datasource.

The goal is to switch the JNDI name of the connection to point to a specific database dynamically.

I created a parameter named "selectedDatabase" that contains the desired JNDI name.

Here is the code:

function init(dataRow)
{
  var jndiDBName = dataRow.get("selectedDatabase");
  if (jndiDBName == null) {
    jndiDBName = "localDB";
  }
  var jndiConnectionProvider = dataFactory.getConnectionProvider();
  jndiConnectionProvider.setConnectionPath(jndiDBName);
}

When running from the Report Designer, everything works as expected, the JNDI "switch" correctly.

But when running on the server, the parameter value is always null.

Checks I made:

  • change the parameter value, the default JNDI is always used
  • remove the "null check" in the script, it crashes
  • I used an other parameter inside the query and this one works (also on the server), so the problem is not the parameter.

I concluded therefore that the script is running correctly and the dataRow.get() always returns null (but only on the server !?!).

 

Does anyone have an idea how to get the parameter value correctly in the Global Scripting? (may be via a different way than dataRow.get() ?)

Is there something that needs to be installed/configured on the server to make it work?

 

Remarks: to reduce alternative solutions, the constraints I have:

 

Kind regards.

Outcomes