Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to access dataset parameters in expressions of property binding?
pdeswert
I have to rewrite a row query in the property binding of a dataset in order to put in the query a list of arguments received in a query parameter as comma-separated values. My dataset works fine if my list of comma-separated values is hardcoded in the expression of the row query:
var qnames = 'SEC::role and profile::TestUC,SEC::security::role and profile::ManageRole'; // test
Next, I try to get the comma-separated values from the dataset parameter with a default value containing the same value than my hard coded string:
var qnames = '$uc_qualified_names';
My dataset query no longer works... :-( So I suppose that this is not the right way to access a dataset parameter. What is the recommended way to access a dataset parameter in the expression of a property binding?
Many thanks for your help.
Find more posts tagged with
Comments
mwilliams
Hi pdeswert,
I'm not sure I'm understanding everything correctly. You have a parameter with multiple values that needs to be passed in the query, so you're trying to do it in the property binding?
pdeswert
Hi Michael,
I try to bind a column to a dataset parameter in the binding of a list element of my report. That column contains strings that are actually comma separated values. I can?t apply the parameter in the row mapping query of the dataset directly (the dataset is a UML dataset and the query is a blend of XPath and OCL but this is irrelevant to my question). I have to insert quotes around the values as following:
var list_qnames = "";
if (qnames.length > 0 ) {
list_qnames = "'" + qnames_param.replace(/,/g,"', '") + "'";
}
I have got two options to write the query:
1. the row query of the dataset property binding.
2. the beforeOpen script of the dataset and assign it to this.queryText
That means that I have to access the dataset parameter either from the row query of the dataset property binding or from the beforeOpen script. The $param syntax works in the row mapping query of the dataset only (and not in the expressions of a property binding of a dataset).
When editing the beforeOpen script the editor (I mean ctrl-whitespace) suggests the following function to access a parameter of the dataset: this.getInputParameterValue("uc_qualified_names")
Does not work :-( I have got the following error:
A BIRT exception occurred.
Plug-in Provider:Eclipse.org
Plug-in Name:BIRT Data Engine
Plug-in ID:org.eclipse.birt.data
Version:2.3.0.v20080606_rev001
Error Code:data.engine.BirtException
Error Message:A BIRT exception occurred: Error evaluating Javascript expression. Script engine error: TypeError: Cannot find function getInputParameterValue.
Script source: <inline>, line: 1, text:
__bm_beforeOpen(). See next exception for more information.
Error evaluating Javascript expression. Script engine error: TypeError: Cannot find function getInputParameterValue.
Script source: <inline>, line: 1, text:
__bm_beforeOpen()
I have tried var qnames = inputParameters["uc_qualified_names"], but to no avail
Apparently there is hidden function to access input parameters: this.getInputParams();
It returns a org.eclipse.birt.data.engine.script.JSInputParams object, but I have got no clue how to retrieve my parameter using a JSInputParams object.
So I return to base my question: how can I access a dataset parameter either from the row query of a dataset property binding or from the beforeOpen script of that dataset?
Many thanks for your help,
Regards,
Pierre
mwilliams
Pierre,
You should be able to get your parameter values with the following script in the dataSet's beforeOpen method.
reportContext.getParameterValue("parameter_name");
pdeswert
Hi Michael,
reportContext.getParameterValue("parameter_name") returns a report parameter. I have to access a dataset parameter (and not a report parameter). By the way in the beforeOpen script, this.getInputParams() returns a JSInputParams object. This is a 'scriptable' object, not subject to java reflection in rhino. I have assumed that I can use the name of the input dataset parameter as a property of that scriptable object but I simply get an undefined object. I mean typeof this.getInputParams().name_of_param == 'undefined'.
Best regards,
Pierre
mwilliams
Pierre,
Ah, my mistake. So, you are not linking the dataSet parameter to a report parameter? You just want to get your default value you have set up in your dataSet parameter?
pdeswert
Good morning Michael,
Yes. Right now, I want to get the default value of the dataset parameter to test my query. Next I want to get the value of the dataset parameter resulting from a dataset parameter binding. In a list element of the report I want to bind that list element to my dataset and bind the dataset parameter (see "Data Set Parameter Binding..." button of the Binding tab) to an 'available column binding', namely the column of another dataset that contains my comma-separated values. I have to build dynamically the dataset query (because comma-separated values in a string...). Therefore I have to access the value of the data set parameter either in the query property binding of the dataset or in its beforeOpen script. Sorry for my lack of precision. I hope that I am clear enough now.
Regards,
Pierre
pdeswert
Hi Michael,
Since I have found no way to access the value of a dataset parameter in the beforeOpen script or in the query property binding I have tried to pass a value trough a report parameter. I assign a value to a report parameter, in the expression of the dataset parameter binding of the list element,
var qnames = row["the_column_name"];
reportContext.setParameterValue("report_param",qnames);
and I get that value in the query property binding.
var qnames = "" + reportContext.getParameterValue("report_param");
Unfortunately that way to pass data to a dataset query is doomed to failure. The beforeOpen script is triggered once only. Similarly, a query property binding produces the expression of the query only one time. In other words, I have passed a first value to the dataset and reexecuted next exactly the same query... I am stuck. Have you got an idea to reset the query expression each time I want to pass a parameter? Many thanks for your help.
Regards,
Pierre
AndyDavey
I've also found that in BIRT 2.5M5 that you cannot access the function 'getInputParameterValue' from the 'open' event of a 'ScriptedDataSet'.
However, you can access the getInputerParameterValue() function from 'beforeOpen'. Why? I have no clue.
My problem at the moment is calling this.getInputerParameterValue("x") always raises an exception saying "Undefined data set parameter". I don't know if it's trying to tell me it can't find the parameter named "x" (which it should since I can see it just below the script in the source xml). Or it's having problems because "x" doesn't have a value yet (which it doesn't ... but that's my problem not theirs).