I am using iReport - my first time using it - and I am trying to make a report that will involve passing a parameter to a subreport. I am not able to get that to work, so I did the following test:
I have a large query that grabs various Fields from my DB - when I preview the report these fields are being pulled and display (over and over, etc., a lot of stuff is being pulled).
I created a new parameter on the main report called "myparam". I made it's default value one of the fields that is being successfully pulled from my DB.
I created a textfield to display this param - the intent being it will echo the field that displays already in my report. If I can get it to do that, I figure I can get it to correctly "plug in" to my subreport.
The issue is - when I preview, I am asked to give the parameter a value - I choose default, which defaults it to the Field I set, which means it should now echo that field (aka I WANT it to echo that field). But it does not echo that field. Instead it just shows null over and over again. Here is a screenshot of what I am talking about
Here is the setup for my report:
Here is proof I've set the default value in my xml:
<parameter name="myparam" class="java.lang.String">
<defaultValueExpression><![CDATA[$F{TCORDERID}]]> </defaultValueExpression>
</parameter>
Here is a snippet of the report which is being generated incorrectly (aka myparam is not getting populated right).
THEY ARE BOTH STRINGS
From my understanding of parameters, they are passed to the report/subreport when it gets created. You have set the default value of the parameter to one of your fields, which has not been populated yet when the report gets generated.
I would suggest adding a simple subreport (which is the reason you want to use parameters anyway), remove the parameter on the main report, and add it to the subreport (with a text field to display it).
Now, add the Parameter to the subreport object in your main report. (This is under the Subreport properties section in iReport.
Name: The name of the Parameter in the subreport.
Expression: The field from your main report that will be passed to the subreport.
So your main report will have the following under the subreport detail:
<subreportParameter name="myparam">
<subreportParameterExpression><![CDATA[$F{TCORDERID}]]></subreportParameterExpression>
</subreportParameter>
And then the Parameter in the subreport:
<parameter name="myparam" class="java.lang.String">
<defaultValueExpression><![CDATA["No result"]]></defaultValueExpression>
</parameter>
Related
I'm developing a report with jasper.
The main report has several subreports.
Only one of these subreport has a fixed text with a note number, something like this.
my text<sup>(2)</sup>
In main report I must print the footnote, but only in all the pages in which the text with the note is present.
An image to better explain:
Is there something that permit to detect if a subreport is present in the current page?
Or something that permit to detect if a detail band is present in the current page?
Or something that permit to detect if a particular text will be printed in current page?
Or other strategy to handle this particular situation?
. Create Variable in main report 'subReportCount'
Type = Integer, default 0
Reset Type = 'Page'
. Place this variable (hidden) somewhere after Subreport
. Create variable 'SubVar' in subreport , expression == $V{REPORT_COUNT}
. In main, go to subreport properties -> Edit return Values - >
Set From Varible= SubVar , To Variable=subReportCount, Calculation type = Sum
. Page Footer Print When Expression = $V{subReportCount} > 0
This may work if you are trying if subreport is printed atleast once in page.
Does not matter if you place subreport variable in report or not.
I tried on my local , its working for similar situation
Variable in Main report
<variable name="subReportCount" class="java.lang.Integer" resetType="Page" incrementType="Page" calculation="Sum">
<variableExpression><![CDATA[$V{subReportCount}.equals( null ) ? 0 : $V{subReportCount}]]></variableExpression>
<initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>
Return Value for the subreport
<returnValue subreportVariable="SubVar" toVariable="subReportCount"/>
Print when expression for Footer element, in my case I am showing Page number
<printWhenExpression><![CDATA[$V{subReportCount} > 0]]></printWhenExpression>
This should work , if not please share your jrxml and sample data.
Good Luck!
I created a simple report in i-report and i added a parameter on a field salary. Now every time i click on preview i get the parameter pop-up to filter. And if the value if not correct i get a blank page. Now that's exactly what i was trying to do. However i am wondering if there's a way to enter a certain value in the parameter box to display all records. Any idea if this possible and if yes how? Thank you.
WHERE EMPLOYEES."SALARY" = ${P1}
You need to change your query (lets imagine that SALARY is numeric, Double). to
WHERE EMPLOYEES."SALARY" = $P{parameter1} OR 0=$P{parameter1}
and define your parameter with a defaultValueExpression and set attribute isForPrompting="false"
<parameter name="parameter1" class="java.lang.Double" isForPrompting="false">
<defaultValueExpression><![CDATA[new java.lang.Double(0)]]></defaultValueExpression>
</parameter>
You will see no more prompt and display all data, if SALARY is of other class naturally you need to adjust the example accordingly.
I need your assistant in passing a value of a parameter in the main report to the subreport. I defined a parameter in the main report which is called {?ReportNumber} and its type is Number and it is static.
In the Select Expert of the Main Report I added the below code:
{engine.reportnumber}={?ReportNumber}
This will take the value of the reportnumber from the table and it will assign it to the parameter. Each time I ran the report, the value will be different based on the retrieved data.
In the Subreport, I created again a parameter with the same name {?ReportNumber} and its type is Number and it is static.
I have added a subreport link which is {?ReportNumber} parameter and below I selected to match the {?ReportNumber} parameter which is in the subreport.
However my issue is that when I ran the report, the report is prompting me to enter the parameter of the subreport, even though I have added and assigned a value to it as I have explained in the above steps.
I am using Crystal Reports 2011
Even tried to use shared variable in the main report:
shared numbervar report_number := {engine.rptno};
report_number;
In the sub report, I create a formula ("Shared_report_number") and I placed it in the report header. It has the code:
shared numbervar report_number;
report_number;
I clicked on Select Expert and then I chose the field {engine.rptno} is equal to {#Shared_report_number}, it produces an error that : the formula cannot be used because it must be evaluated later
Kindly assist me in passing the value of the parameter from the main report to the subreport.
This prompting shows that your parameter is not link properly.
When you link the parameter. In left side, main report parameter show
1. is of sp parameter
2. is of custom report parameter
While you linking, note that you custom report with report name is joined.
Please check this below link, in UI potion of third image , right-bottom side you have to choose sub-report parameter. So check and then link.
http://blog.niklasottosson.com/?p=1137
In your case, I think your main report parameter is link with itself. not with subreport parameter.
Check this link carefully while mapping.
I'm using iReport Designer 5.5.0, and was making a test JRXML. I added a text field with a value of $F{pricing_date} and added "pricing_date" to the list of "fields" on the Report Inspector panel (no properties or description set for the field).
The resulting JRXML has the "pricing_date" field defined:
<field name="pricing_date" class="java.lang.String"/>
And it has a text field with $F{pricing_date} as expected:
<textFieldExpression><![CDATA[$F{pricing_date}]]></textFieldExpression>
But... I get the error "Field not found : pricing_date" within iReport, and I get the same error during compilation.
I've compared this to other JRXML files within the samples provided, and it seems to match... what am I missing? Is there a setting somewhere to recognize field definitions?
I can see two possible reasons here.
If the report does not compile, the problem might be that the element in which you have placed the textField uses a different datasource than the one in which you have declared the field.
If it does not run, you might be missing the field in the object type of the datasource. Also, if you use JRBeanCollectionDataSource from java you have to have the getter for your field (declared as getPricing_date(){...}).
Hope this helps.
I'm using Visual Studio 2008 BIDS to create a report that contains a sub report. This is only the second ssrs report I've created so forgive me if I'm not using the correct terminology. Right now when I try to preview the report in BIDS I get this error message:
[rsWarningExecutingSubreport] Warnings occurred while executing the subreport ‘lineItemsSubReport’.
[rsNone] The report parameter 'salesOrderId' is read-only and cannot be modified.
[rsNone] The report parameter 'salesOrderId' is read-only and cannot be modified.
[rsNone] The report parameter 'salesOrderId' is read-only and cannot be modified.
[rsNone] The report parameter 'salesOrderId' is read-only and cannot be modified.
On the subreport, my parameter was set to internal, but I have changed to it hidden.
I'm using FetchXMl for the query for both reports.
My main report contains a data set that has a field called salesorderid. I'm trying to pass this value to the sub report doing this:
<Subreport Name="lineItemsSubReport">
<ReportName>LineItemsSubReport</ReportName>
<Parameters>
<Parameter Name="salesOrderId">
<Value>=Fields!salesOrder_salesorderid.Value</Value>
</Parameter>
</Parameters>
<Top>0.38542in</Top>
<Left>0.125in</Left>
<Height>0.62499in</Height>
<Width>5.98958in</Width>
<ZIndex>1</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Subreport>
In my sub report I have a filter on the query and a Query Parameter named salesOrderId and a Report Parameter called salesOrderId. Is this setup right? If not how do I setup the sub report to get the parameter that is passed from the main report? This seems like it should be easy, but it's being a bit of a pain.
Thanks!
Well I somehow got it to work, but I'm not quite sure what excatly I did that did it. I will post the answer if I figure it out.