问题
I want to pass the parameters in the URL of the BIRT Report. In my reports there are 3 parameters like StoreId, fromdate and todate. I have also tried to write the code of beforeOpen Script of my dataSet in the Birt. Its is as :
var store_id;
var from_date;
var to_date;
store_id = params["Store_id"].value;
from_date = params["fromdate"].value;
to_date = params["todate"].value;
this.queryText = this.queryText+" where STORE_ID = "+store_id+" AND TRANSFER_DATE BETWEEN "+from_date+" AND "+to_date+ "ORDER BY TRANSFER_DATE ASC";
And i wrote my URL as :
http://localhost:8080/birt/run?__report=adminMasterTransferReport_new.rptdesign&Store_id=1&fromdate=2014-04-26&todate=2014-06-06
At the end of the report I am getting such error :
The following items have errors:
ReportDesign (id = 1):
+ There are errors evaluating script "var store_id;
var from_date;
var to_date;
store_id = params["Store_id"].value;
from_date = params["fromdate"].value;
to_date = params["todate"].value;
this.queryText = this.queryText+" where STORE_ID = "+store_id+" AND TRANSFER_DATE BETWEEN "+from_date+" AND "+to_date+ "ORDER BY TRANSFER_DATE ASC";
":
Fail to execute script in function __bm_beforeOpen(). Source:
------
" + var store_id;
var from_date;
var to_date;
store_id = params["Store_id"].value;
from_date = params["fromdate"].value;
to_date = params["todate"].value;
this.queryText = this.queryText+" where STORE_ID = "+store_id+" AND TRANSFER_DATE BETWEEN "+from_date+" AND "+to_date+ "ORDER BY TRANSFER_DATE ASC";
+ "
-----
A BIRT exception occurred. See next exception for more information.
Report parameter "Store_id" does not exist..
If anyone knows then help me.
回答1:
Make sure the Report Parameter Name matches the one given in the URL. You are looking for the Report Parameter named "Store_id" in this script but in the first paragraph of your question you state the name as "StoreId". I think you need to change the Report Parameter name from "StoreId" -> "Store_id".
来源:https://stackoverflow.com/questions/23933326/how-i-can-populate-data-in-birt-report-by-passing-parameters-in-the-url