Jasper Server: passing argument to get report data for customer

左心房为你撑大大i 提交于 2019-12-11 08:57:45

问题


I have almost the problem described here: iReport: Passing parameters from a main report query to a dataset query for a table or list

but since it's a few years old, I'm using iReports 5.1 with the newest comnunity version of Jasper Server.

I am able to fetch reports by PHP from the server, but I want to pass a parameter to the report to only display information for a distinct customer, having something like customerId in the database. So it only generates a report for a give customerId.

I don't want to create a single report for every customer.

How can I pass arguments to the datasource/main report, through the API?

Additional question: Is it possible to add this argument/parameter to scheduled reports?


回答1:


Add to the report (XML):

<parameter name="CUSTOMERID" isForPrompting="false" class="java.lang.String">
</parameter>

In the datasource (mongodb):

{'collectionName':'test', findQuery : { customerId: $P{CUSTOMERID} }}

passing the argument:

 ws_runReport($currentUri, $report_params,  $output_params, $attachments);

Hope this will help someone else, too.



来源:https://stackoverflow.com/questions/17317736/jasper-server-passing-argument-to-get-report-data-for-customer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!