Home
Intelligence (Analytics)
assign parameter values using scriplet datasource
purushdk
Hi,
Am using birt all in 2.5.1 and db oracle 10g
i have table called dept,
where i am columns like dep_code,dep_name
dep_code is number data type.
its possible to assign parameter values and dispaytext through scriplet data source.
its possible please provide example.
Thanks & Regards,
k.purushothaman
Find more posts tagged with
Comments
mwilliams
Hi k.purushothaman,
Are you talking about dynamically grabbing the values from your dataSet for use in your report parameter?
purushdk
Hi
Exactly
mwilliams
k.purushothaman,
Are you not able to use a list box type parameter with the dynamic option selected?
zmirovic
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>Hi k.purushothaman,<br />
Are you talking about dynamically grabbing the values from your dataSet for use in your report parameter?</p></blockquote>
<br />
I am also interested is that possible and how?
mwilliams
Hi zmirovic,
To use a dynamic parameter, you just need to create a dataSet for just the parameter that pulls in only the field you want the user to select from. You then create a report parameter and attach it to this dataSet. You choose the list box type parameter and then the dynamic radio button. Then, fill out the rest of the needed info. Then, you can tie this report parameter to another dataSet that you want to limit based on the user's input, etc.
Hope this helps.
zmirovic
I don't want to do that.
I want to use parameters stored in DB in form:
key1 value1
key2 value2
...
as parameters for scripts, not for data set.
I make parametrized data set which is returning exact data what I need and after that I want to do something like this:
reportContext.setParameterValue(dataSetRow["key"], dataSetRow["value"]);
bhanley
When you modify the onFetch event of your scripted data set you assign values form a POJO to fields on a data set row. This is the point you should be able to do what you are looking for. I would use the values in the POJO, not the row as the table is still being build at that point and may not be reliably accessible.<br />
<br />
You need to remember the onFetch event is invoked for each "row" of your Scripted source (POJO). So you need to decide on what iteration you set your report parameter. Then there is one additional layer of complexity in that you are naming the parameter dynamically. How do you plan on knowing how to access this value?<br />
<br />
An alternative that may be easier to do is to set a Persistent Global Variable. This is a variable that is available across the various contexts of a BIRT report. I would give it a consistent name that would allow you access it easily anywhere you want. Then just create some kind of name/value pair in the value of the variable and you would be all set.<br />
<br />
Example:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
// Values from POJO...
var Name = "myDynamicParam";
var Val = "Some Dynamic Parameter Value";
</pre>
<br />
Set the value to use Later:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
// Create Name/Value Pair
var nvp = Name + ":" + Val;
reportContext.setPersistentGlobalVariable("globalParam", nvp);
</pre>
<br />
Access the value anywhere in your report:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var nvp = reportContext.getPersistentGlobalVariable("globalParam");
// split nvp and use the name and value however you want...
</pre>
<br />
Does that make sense? I think that is actually a much easier and cleaner approach to sharing the data across the report context.<br />
<br />
Good Luck!
zmirovic
Thanks.
I need exactly what I described
Keys are well defined, so accessing parameters is not a problem. Report contains n reusable data sources / tables (iterated by container table) which are tailored with those parameters.
It will be the best, if I can join multiple reports in to one, but I hope this workaround will do the same.
bhanley
There may be some level of misunderstanding as to what I laid out, because the path I gave you is a more flexible route to using values from a scripted data source anywhere in a report including as a parameter to another dataset.