0
votes

I have a report that I created in iReport professional 4.5.1 and have deployed to JasperServer. I have a parameter in my report that is used to specify a sorting column:

Name: profit_loss_sort
Parameter Class: java.lang.String
Use as a prompt: Yes
Default Value Expression: "FAC_ID"

Then I have another parameter that takes $P{profit_loss_sort} and uses it to create an ORDER BY clause for my query:

Name: profit_loss_sort_function
Parameter Class: java.lang.string
Use as a prompt: No
Default Value Expression: "ORDER BY "+$P{profit_loss_sort}+" ASC"

When $P{profit_loss_sort} is set to visible, this works fine in iReport and on JasperServer. I have set a hyperlink on each column label and when you click on those, the report sorts on each column.

When I uncheck the visible box for $P{profit_loss_sort} attempt to run the report for the first time I get an Oracle error that I'm missing an expression (ORA-00936: missing expression). I don't understand that because the ORDER BY clause in my query is:

$P!{profit_loss_sort_function}

so JasperServer should take the defaults of those two parameters and come up with an ORDER BY clause. In fact, when I run the report from iReport using the "Run JasperServer Report" option it acts appropriately and fills in the default ORDER BY clause. $P{profit_loss_sort} is mandatory and on the JasperServer side I have unchecked "always prompt" for my input controls.

I don't want $P{profit_loss_sort} to be a visible input control, but I still want it to use the default value the first time the report is run. Any thoughts?

1

1 Answers

1
votes

I figured it out - I have a main report that is passing parameters to a subreport. I had set a default value for parameter $P{profit_loss_sort} in the subreport, but not in the main report.

I set a default value for it in the main report, and now when I uncheck that "visible" box, the JasperServer report hides that input control and I can sort using my hyperlinks.