如何通过在URL中传递参数来填充birt报告中的数据

时间:2014-05-29 12:27:34

标签: birt url-parameters

我想传递BIRT报告网址中的参数。在我的报告中有3个参数,如StoreId,fromdate和todate。我还尝试在Birt中编写我的dataSet的beforeOpen 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";  

我把我的网址写成:

http://localhost:8080/birt/run?__report=adminMasterTransferReport_new.rptdesign&Store_id=1&fromdate=2014-04-26&todate=2014-06-06

在报告的最后,我收到了这样的错误:

以下项目有错误:

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..

如果有人知道那就帮助我。

1 个答案:

答案 0 :(得分:0)

确保报告参数名称与URL中指定的名称相匹配。您正在寻找名为" Store_id"的报告参数;在此脚本中,但在问题的第一段中,您将名称命名为" StoreId"。我认为您需要更改" StoreId"的报告参数名称。 - > " STORE_ID"