Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Report Parameters and Datasource Property Bindings
zax
Hello,<br />
<br />
I am trying to produce a report that can be pointed at a large number of identically structured databases. I was hoping to use a report parameter to determine which data source to use. But when I attempt to do this by adding code like this to the <strong class='bbc'>JDBC Driver URL property binding</strong>:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var project;
var keyword;
switch(params['keyword'].value) {
case "database_1":
project = "project_1";
keyword = "database_1";
break;
case "database_2":
project = "project_2";
keyword = "database_2";
break;
}
// Use the project keyword to determine the DNS address and the database name.
"jdbc:mysql://" + project + ".thoreb.se:3306/" + keyword + "_statistics";</pre>
<br />
I get the error:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>Error Message:Error evaluating Javascript expression. Script engine error: Report parameter "keyword" does not exist.
Script source: <inline>, line: 0</pre>
<br />
The report parameter does indeed exist, because if I run the report in preview, the parameter value can be displayed.<br />
Does anyone know why this does not work? Is there another (better) way of achieving this?<br />
<br />
Many Thanks,<br />
Stephen
Find more posts tagged with
Comments
pricher
Hi Stephen,
Make sure your parameter name is spelled correctly. I have no problem running your script when creating a parameter called 'keyword'.
P.
zax
Well.. that is not the problem. I have added a screen shot of the edit parameter box.. as you can see the report parameter name is spelt correctly.
zax
Hi,<br />
<br />
I have just tried it with a fresh report.. I still get the error. I think this is an IDE error because the error starts with:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>A BIRT exception occurred.
Plug-in Provider:Eclipse.org
Plug-in Name:BIRT Core Package
Plug-in ID:org.eclipse.birt.core
Version:2.6.2.r262_v20110209
Error Code:birt.core.JavascriptError
Error Message:Error evaluating Javascript expression. Script engine error: Report parameter "keyword" does not exist.</pre>
The report preview seems to work OK too.. OK I guess I have to live with it.. unless anyone knows a fix.<br />
<br />
Thanks,<br />
Stephen
zax
Because of this error the IDE would not let me create dynamically driven lists or anything. It seems data set meta data was not available and I was not able to select columns for display or values. The work-around is to not use a dynamic data source and to use a hard coded one and to apply the dynamic one (based on the case statement posted earlier) when the report was complete.<br />
<br />
But then I have started to notice a pattern.. whenever I try to use a report parameter in a property binding, be it the data source or a query, I get the error. The report parameter is available to be displayed within the report, just not available to property bindings. <br />
<br />
Is this an Eclipse plugin bug? It is starting to feel like one....<br />
<br />
EDIT 1: Additional: I get this error on both Linux and Windows XP platforms (Helios SP2).<br />
<br />
EDIT 2: For those of you who may think it is a typo.. here is a segment from the XML:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><scalar-parameter name="keyword" id="533">
<property name="hidden">true</property>
<property name="valueType">static</property>
<property name="isRequired">true</property>
<property name="dataType">string</property>
<property name="distinct">true</property>
<simple-property-list name="defaultValue">
<value type="constant">ch_lenzburg</value>
</simple-property-list>
<property name="paramType">simple</property>
<property name="controlType">text-box</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter></pre>
zax
This is still an issue, so as a work-around I use a data source that does not have any property bindings for development, so table meta data can be retrieved. I also think that the Eclipse IDE handles default values for report parameters in an inconsistent (and hidden) way. Sometimes they seem to work, and other times (especially when trying to define a dynamic data source) they do not.
Ho Hum....
mcremer
<blockquote class='ipsBlockquote' data-author="'zax'" data-cid="75588" data-time="1302179194" data-date="07 April 2011 - 05:26 AM"><p>
This is still an issue, so as a work-around I use a data source that does not have any property bindings for development, so table meta data can be retrieved. I also think that the Eclipse IDE handles default values for report parameters in an inconsistent (and hidden) way. Sometimes they seem to work, and other times (especially when trying to define a dynamic data source) they do not.<br />
<br />
Ho Hum....<br /></p></blockquote>
<br />
I have the same problem ever since I upgraded to BIRT 2.6.2.<br />
<br />
I created the folowing property binding:<br />
<br />
"jdbc:oracle:thin:
@ + params[
log_host"].value + ":" + params["log_port"].value + ":" + params["log_sid"].value + ""<br />
<br />
When I try to check a data set I get the folowing error (afther I successfully previewed results).<br />
<br />
When I close the data set I get the folwonig error:<br />
Error message:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>Error evaluating Javascript expression. Script engine error: Report parameter "log_host" does not exist.
Script source: <inline>, line: 0, text:
"jdbc:oracle:thin:
@ + params[
log_host"].value + ":" + params["log_port"].value + ":" + params["log_sid"].value + ""</pre>
<br />
Detail info:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>A BIRT exception occurred.
Plug-in Provider:Eclipse.org
Plug-in Name:BIRT Core Package
Plug-in ID:org.eclipse.birt.core
Version:2.6.2.r262_v20110209
Error Code:birt.core.JavascriptError
Error Message:Error evaluating Javascript expression. Script engine error: Report parameter "log_host" does not exist.
Script source: <inline>, line: 0, text:
"jdbc:oracle:thin:
@ + params[
log_host"].value + ":" + params["log_port"].value + ":" + params["log_sid"].value + ""
</pre>
micajblock
<p>I think the issue is where your code it. Setting it on the data source itself is too late. You need to put the code in the beforeFactory event of the report. The code should then look like this:</p><pre class="_prettyXprint _lang-js">var project;var keyword;switch(params["keyword"].value) { case "database_1": project = "project_1"; keyword = "database_1"; break; case "database_2": project = "project_2"; keyword = "database_2"; break;}// Use the project keyword to determine the DNS address and the database name.reportContext.getDesignHandle().findDataSource("Data Source").setProperty("odaURL","jdbc : mysql : //" + project + ".thoreb.se:3306/" + keyword + "_statistics");</pre>