问题
I have a BIRT report that uses a query like below.
select
Dealer,
Name
from customerA where id = ?
union all
select
Code as Dealer,
last_name as Name
from customerB where id = ?
union all
select
Num as Dealer,
owner as Name
from customerC where id = ?
I have a input text box in the report itself and a refresh button which reload the report. also my report have parameter called 'CUST_ID' which i bound in the dataset as param_1,param_2 and param_3 to replace with '?' mark while executing.
if i enter the parameter on parameter popup screen report works fine , but i need to enter the id in the text box and once i press the refresh link reload report accordingly.
How can i add the input text value ( i know i can get it from a script ) and set it to the report parameter 'CUST_ID' ?
Highly appreciate your help.
Thank you in advance.
回答1:
I was able to fix this by using scripts in BIRT. below i listed the steps i follow.
1.add a script that will initiate the request parameters on page load.
report url i was able to access by using var link=this;
inside a normal javascript function.
2.Append my parameter to the end of the request as mentioned by james above. thanks james.
3.replace the newly created url link.href=url;
This will refresh the report with the value i entered in the input box.
4.in data set i modified my query as 'Select name from customerA'
without any where clause.
5.dataset beforeOpen
script i added these line and records are filterd accordingly.
this.queryText += "where id ="+reportContext.getParameterValue("cust_id");
reportContext.setParameterValue("debug", this.queryText);
来源:https://stackoverflow.com/questions/20992465/birt-reports-add-parameter-through-script