I'm creating a jasper report using iReports 5.2.0 and I want to display the report file name in it.
Can't find any variable that has that information and I would like to get an alternative to pass it in the parameters.
How can I do it?
When you design your report, make a new PARAMETER named, for instance: NAME_REPORT.
After that, put a TextField in your report, for example, in your Title section, and
put as value of your TextField the parameter like a expression: $P{NAME_REPORT}
When you preview your report, ask you to give a value to this parameter and then, you see the title with the name
of your report file.
In your java code you will do somethink like that:
parameters.put("NAME_REPORT", "myreport.jrxml");
.....
JasperFillManager.fillReport(report, parameters, connection)
.....
Related
I'm unable to link an Input Control to my report's Parameter. I feel I'm doing right, but I can't see the desired result in the final report.
My intention is to create a list, filled by some options, and display the list in a report as a parameter, so the user can (multi)select the options. As far as I know, I must create an Input Control on the server, create a Parameter on the report using the same name between the Input Control and the Parameter.
I've created a List of Values named ListaCalificaciones as follows:
Then, this is the Input Control:
Finally, this is the parameter:
However, when it comes to show the report on Jasper Server's web interface, I can't see a filled input:
Am I missing something?
By the way, I'm using Jasper Studio 6.6.0 and Jasper Server 7.1.0 (compiled version 20180504_1307).
Edit 2018/10/05 13:04
I've changed the input control, so that the id is ic_calificaciones and the name stays as it was (Calificaciones). I've found a way to make it work. First, I deploy the report to my server (local server in my case). Then, I edit the report, go to "Controls and resources", remove the ic_calificaciones parameter and add a InputControl parameter to the report. That way the Calificaciones parameter gets filled up with options.
I found the solution, it was just in front, but due to a poor UI I just didn't realise...
You must edit your parameter's name to match the Input Control's name, in my case it ought to be ic_valoracion. Then, the parameter-to-input-control-binding has to be made when publishing the report to the server.
So, being in Jasper Studio, click on publish button, as seen in the following picture:
Now, select the location where to publish the report. Then, the second step is what we're looking for, it's the place where you must select the resources to publish. As seen in the next image, you must edit your parameter's type to select "Link To Resource", click on whichever place and a new prompt will appear. Now, there, select the desired Input Control.
Finally, test your report.
Is it possible to mark a report based on the times we click Preview?
For example, if we preview the report once, it will show 1.
If we preview the report twice, it will show 2.
I am using Adempiere and would like to put the report inside the window. So, when I click 'Print' once, it will show 1, the same when I click Print for the second time it will show 2, etc.
Any suggestion will be useful :)
There is a field in the AD_Process table called Statistic_Count which function is to store how many times the process has been run.
What I would do is to pass the value of that field as a parameter to the report, so you can print it.
In the process parameter you could add a new numeric parameter called PreviewTimes and in the DefaultValue field set something like:
#SQL=SELECT statistic_count FROM AD_Process WHERE AD_Process_ID = #AD_Process_ID#
Then, in the Jasper Report you receive that number and include it.
Hope it helps.
Suppose,One main report can have 9 sub-reports.
Then user can have UI from which user can order the sub-report according to his/her choice.(like,which sub-report should be displayed first and which is next and so on).
SO,how can i achieve this ?
Follow the below steps to achieve your requirements
Create 9 parameters say, reportpath1,reportpath2,reportpath3,....reportpath9.
Prompt user to enter the order of the reports. Based on the order pass the respected report path to every parameter.
Meaning, if subreport9 is selected as 1st report, then pass the path of that subreport9 as reportpath1, if subreport8 is selected as 2nd report, then pass the path of that report as reportpath2 and so on
For example, if path of subreport9 is "report/samples/subreports/subreport9", then set parameter reportpath1 value as "report/samples/subreports/subreport9". If path of subreport8 is "report/samples/subreports/subreport8", then set paramter reportpath2 value as "report/samples/subreports/subreport8" and so on.
In report design, create 9 subreport and instead of hard-coding the path of each report, pass parameter in subreportexpression as below
For subreport1,
<subreportExpression><![CDATA[$P{ReportPath1}]]></subreportExpression>
For subreport2,
<subreportExpression><![CDATA[$P{ReportPath2}]]></subreportExpression>
and so on.
Hope this should solve your problem.
Answer for getting variable from subreport
Right click on subreport in Parent report.
Go to Properties
Under Subreport session, click "Return values"
Add the subreport variable and map it to the parentreport variable.
Then use that parentreport variable in your parent report.
Hope this should solve your another problem.
JasperServer doesn't pass parameter from input control to the report for some unknown reason.
I defined a jrxml report with iReport 4.6 (even tried compatibility mode 4.0.1) using input parameter which works in iReport.
When I deploy the report on jasperserver 4.5 the response I get is "The report is empty".
Same report without parameter works also well.
Naturally I defined and attached input control with single-select query.
The value column and the visible column in input control is the same DB field I use as parameter in jrxml.
Query values as possible input are displayed fine, but when I choose one..."The report is empty"!!.
I tried simplifying the report but my parameter from input control just wont be passed through to render the report.
You must create the parameter in jasperserver too (not only in iReport), with same name.
In JasperServer, edit your report, define "Input controls" with same ids and go thru wizard, it should work now.
If you like to test first select "Always require in emergin window".
You can also look at the answer here http://jasperforge.org/node/543148
Can anyone tell me, how to pass parameters to crosstab?
I use Jaspersoft Studio (5.6.2) for designing the reports.
select the crosstab, in the report it is placed. Then goto properties. Then select the tab Advanced. Here you can find the property -Parameters Map Expression-, as value you put what Stoian writes above: $P{REPORT_PARAMETERS_MAP}
Make sure you have a parameter created with the same name you want to use in the crosstab, in the report the crosstab is placed. Put nothing in the -Default Value Expression- if the value is comming from a parent subreport.
in the crosstab (by double clicking on it) goto the Outline. Here you find Parameters, I also created a parameter here with the same name, setting the -Default Value Expression- to the $P{ here you put the name of the parameter you used in point 2 }
seems to work
If you are using iReport or any other report designer, just embed the crosstab into the main report. If you click on the crosstab element and expand it, you will get to see the 'parameters' section. Right-click on the 'parameters' section to add a new parameter and name it accordingly. In the 'Value Expression' for that crosstab parameter, select the parameter from the main report (The report holding the crosstab). Voila!
Do just like bchetty says, just do not forget to add the parameterMapExpression in the crosstab properties of the crosstab. For Report parameters it should be $P{REPORT_PARAMETERS_MAP}
First Make the cross tab in an another report && import it into your main report. Now right click on the subreport you will get an option of change subreport links Where you can put your parameter field to pass in cross tab report.