I publish a report in jasper server.The report contains two parameter, customer_id and query. The parameter query is an array and its class is java.util.List. The report is working in jasper soft studio. But i cant set parameter in jasperserver please refer the below image
How can i set array parameter in that query field?
You should set java.util.Collection instead of java.util.List as the class if you want to multi-select list values.
Refer to this link for detailed instructions.
If you wanna just have single select from the list then set the class to String or number.
Related
I am working on Jasper Reports and my query uses SQL 'IN' predicate.
SELECT customer_name AS NAME,
id_customer AS ID
FROM customer
WHERE customer_role IN ($P{roles})
Here the role parameter can have 1 or more integer values and will be dynamically decided when generating the jasper report.
Can anybody please help me on how to set the value of 'roles' parameter thru Java program dynamically.
Jasper Report has a special variable $X for that:
select * from customer where $X{IN,customer_role,roles}
should work. See here and here.
The examples linked to in the accepted answer don't come up for me.
An alternative that worked for me is instead of using:
...
WHERE customer_role IN ($P{roles})
I used this:
...
WHERE customer_role IN ($P!{roles})
And for the roles variable I pass in a String containing one or more values, each in single quotes, separated by commas (e.g., '1','2','3').
See here for reference.
To complement #Aaron response, you can configure a list parameter ("roles" in your case) within JasperSoft Studio as follows:
I am working on Jasper Reports and my query uses SQL 'IN' predicate.
SELECT customer_name AS NAME,
id_customer AS ID
FROM customer
WHERE customer_role IN ($P{roles})
Here the role parameter can have 1 or more integer values and will be dynamically decided when generating the jasper report.
Can anybody please help me on how to set the value of 'roles' parameter thru Java program dynamically.
Jasper Report has a special variable $X for that:
select * from customer where $X{IN,customer_role,roles}
should work. See here and here.
The examples linked to in the accepted answer don't come up for me.
An alternative that worked for me is instead of using:
...
WHERE customer_role IN ($P{roles})
I used this:
...
WHERE customer_role IN ($P!{roles})
And for the roles variable I pass in a String containing one or more values, each in single quotes, separated by commas (e.g., '1','2','3').
See here for reference.
To complement #Aaron response, you can configure a list parameter ("roles" in your case) within JasperSoft Studio as follows:
I'm trying to pass a collection parameter to a report. This report is shown inside an IFRAME and I'm passing the parameter this way:
I want to insert a report in an iframe in my web application.
The report has a "collection" parameter IdTurno. In the query-string I'm passing values this way:
http:jasper_server_url?ids=1,2,3
but this doesn't work.
What's the correct way to pass collection parameters via query string?
Can't find documentation about this.
Note I'm using JasperServer community edition v.5.1
I wanted to create a JasperReport which asks the user for a deliverer before it creates a report with data of the last the deliveries of the selected deliverer.
The problem, how I can do that? I found only examples where a parameter is created and the ArrayList is filled statically. But in my parameter I need the query result over the table of deliverers filled.
Can anybody tell me a possible solution?
I'm using Jaspersoft Server 5.1 which directly access a PostgreSQL database which has a datawarehouse structur. So it's not possible to use Java code.
Here is the documentation for adding input controls to reports in JasperReports Server:
http://community.jaspersoft.com/documentation/jasperreports-server-user-guide/adding-input-controls
Scroll down to the section that deals with query-based input controls. Your input control will have a name, such as deliverer. In your report, you must add deliverer as a parameter and reference it in your query, as you have done in your comment.
I have a simple SSRS report that displays data from one table. What I want to do is have a distinct list from that table displayed in a drop down list for the user to select. If I only use one dataset I can get it to display, but it displays values from the column multiple times.
Example
Bob
Bob
Bob
Cathy
Cathy
If I create a second dataset that will list distinct values I get the following error message:
An Error occurred during local report processing. The definition of the report is invalid. The Variable expression for the report 'body' refers directly to the field without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope.
I"m trying to follow the example I found here:
http://msdn.microsoft.com/en-us/library/aa337400.aspx
The second dataset is only for the parameter list. I don't understand why it's causing problems with the actual report.
It's impossible to tell exactly where without the report definition, but there is an item on the report that is referencing a field or Dataset, and was implicitly using the only Dataset present in the report, but now doesn't know which Dataset to use once more than one is added to the report.
For example, when you create a table you can set a Dataset associated with it. If this is not set and there is only one Dataset, it doesn't matter as it will take the only one available. Once you add a new Dataset, the table doesn't know which one to use and you'll get the error you're seeing.
Another way to get the error is specifying a field in an expression, e.g. in a TextBox in the report somewhere without specifying the scope; just set the scope to a particular Dataset e.g. if you have:
=Count(Fields!name.Value)
change this to:
=Count(Fields!name.Value, "DatasetToUse")
If you've only got one Dataset the first expression will run fine by using the only one available, but once you add another it won't know which to use and it will error.
in the query (SQL) you should add DISTINCT clause at the beginning, that way, you will get only one record per value. Check out http://www.w3schools.com/sql/sql_distinct.asp
Double click the Dataset which contains that field.
Go to fields on the left and delete that field.
Add new field by clicking Add -> Query Field.
Just type in the name of the new field under field name and field source.
It happens when you have added a field by selecting "Calculated Field" instead of "Query Field" from Dataset Fields list tab.
Cheers,
Ahmed Latif