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 pass Multi Select Params to BIRT report from frondend
AravindRam
Hello All,
I am pretty new to BIRT. I would like to know the best way to pass multiple params (list of string values) from frond end (GWT) to Birt report. Essentially, these params should be part of IN clause in the sql.
Though i have browsed though some articles in the internet but they were quite old posts. I would like to know the best and easiest way to achieve this functionality. Btw i am using Birt 3.7 version.
Any help is highly appreciated..
Thanks,
Aravind Ram
Find more posts tagged with
Comments
bgbaird
I do this by passing the entire string in the call as a parameter, then parse it in the initialize script.
AravindRam
<blockquote class='ipsBlockquote' data-author="'bgbaird'" data-cid="100441" data-time="1337111611" data-date="15 May 2012 - 12:53 PM"><p>
<span class='bbc_underline'>I do this by passing the entire string in the call as a parameter</span>, then <del class='bbc'>parse it in the initialize script.</del><br /></p></blockquote>
Hi, <br />
Thanks for your reply. I understood the first part of your statement which is preparing a comma seperated string of selected values from the Java side. Could you please elaborate more on the initialize script part as to how and where is it done. May be small writeup might help people like :-)<br />
<br />
Once again thanks...
ANNKRUSE
<blockquote class='ipsBlockquote' data-author="'AravindRam'" data-cid="100552" data-time="1337115426" data-date="15 May 2012 - 01:57 PM"><p>
Hi, <br />
Thanks for your reply. I understood the first part of your statement which is preparing a comma seperated string of selected values from the Java side. Could you please elaborate more on the initialize script part as to how and where is it done. May be small writeup might help people like :-)<br />
<br />
Once again thanks...<br /></p></blockquote>
<br />
I would be very interested in this also. I am on ver 2.6. Thank you so much!
CBR
Hi,
If your BIRT report parameter has option allow multiple values checked you need to pass it as an array of appropriate type. String parsing can be difficult (what do you do if one value contains a comma), but sometime is the only option if you don't want to check allow multiple values option.
bgbaird
I am attaching an example I put together.<br />
<br />
In this report there are three parameters:<br />
<br />
"masterParamFromApp": two seperate strings seperated by ";". Each string is seperated by ",".<br />
<br />
Bow,Firrelli,Jennings;1102,1088 <br />
<br />
We want results that have (last names = Bow, Firrelli, or Jennings) OR (reportsto = 1102, or 1088). <br />
<br />
REPORT INITIALIZE:<br />
Assuming we pass "masterParamFromApp" from the requesting app, <br />
we parse it out and assign values to 2 more parameters:<br />
<br />
"paramLastName" and "paramSto"<br />
<br />
//Set params["paramSto"].value to the a_paramMaster[1] buried in parens<br />
params["paramSto"].value="("+a_paramMaster[1]+")";<br />
//In the example, now params["paramSto"].value == "(1102,1088)"<br />
<br />
//Split a_paramMaster[0] into a new array "a_paramLastName"<br />
var a_paramLastName=new Array();<br />
a_paramLastName=a_paramMaster[0].split(",");<br />
<br />
//Set params["paramLastName"].value into a string buried in parens<br />
params["paramLastName"].value="(";<br />
for (i=0;i<=a_paramLastName.length;i++)<br />
{<br />
params["paramLastName"].value=params["paramLastName"].value+"\'"+a_paramLastName
+"\'"<br />
if(i<a_paramLastName.length){params["paramLastName"].value=params["paramLastName"].value+",";}<br />
}<br />
params["paramLastName"].value=params["paramLastName"].value+")";<br />
//In the example, now params["paramLastName"].value == "('Bow','Firrelli','Jennings')"<br />
<br />
DATASET BEFORE OPEN SCRIPT:<br />
<br />
this.queryText=this.queryText+" AND (LASTNAME in "+params["paramLastName"].value;<br />
this.queryText=this.queryText+" OR REPORTSTO in "+params["paramSto"].value+")";
bgbaird
If you are concerned parsing around commas, you can use a more distinctive separator when you build your report call.
as an example:
exString "abc,def,ghi" is parsed into an array with a_arrayname=exString.split(",")
exString "abc^def^ghi" is parsed into an array with a_arrayname=exString.split("^")
exString "abc;@;def;@;ghi" is parsed into an array with a_arrayname=exString.split(";@;")
Good examples at
http://www.w3schools.com/js/js_obj_array.asp