I am looking for a way to use the current user locale information in a sql query for the input control in JasperServer.
More details:
The input query should present a list of values which it obtains via sql query from our database. However, this values depends on the user locale information.
Within the report I can use $P{REPORT_LOCALE} to get the user locale. However, this parameters does not work in the queries used to populate the input controls.
I appreciate every hint.
I actually figured it out how to do it.
My solution: create an invisible input control of type string and assign it to the report. Define a report parameter with the same name and set the default value expression to $P{REPORT_LOCALE}.getLanguage(). By doing that I am able to use the language code of the current user via the input parameter in sql queries.
Related
In AppMaker, one my datasources has a simple query script associated with, because I need a filter everytime the datasource is requested. I'm talking about a normal SQL based datasource (not calculated).
Is it normal than this query script is not used when the datasource is used in a Suggest box ? Because it breaks my app (the user is able via the suggest box to select items he's not even supposed to see).
Thanks for your help
The options for a suggest field text box can either be provided explicitly, by binding to the options property, or by specifying a database query on a model using a startsWith filter on a field. You can set the model and field for the latter option below.
So you can try to create calculated model with server script starts with
var name = query.filters.name.startsWith;
name is field of model
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 report which creates a list of Events for a specified date range and event type.
The date range and event type are parameters defined in the report. The date parameters (#DateFrom and #DateTo) work as they should.
The #EventType parameter however, which is defined as a list of values provided by a DataSet (with 'Allow Multiple values' checked), does not provide the expected behaviour when using the {Select All} check box. If I select one or more Event Types by checking several boxes on the list, the report will show the Events which match the specified Event Types correctly.
However, if I click the {Select All} box (which then highlights all of the other possible values), the report does not show the Events for all of these Event Type values. It seems to miss out several of the values which are selected by the {Select All} box. If I run the report specifically for those missing values, the report returns events matching those types. This indicates to me that there is not a lack of data for these types.
And for that reason, it looks to me like the {Select All} is bugged...or perhaps cached somewhere? I've tried deleting the report/parameter dataset and redeploying to no avail. It's worth noting that this behaviour happens locally before deploying it, too.
Has anyone seen this before, or does anyone have any suggestions?
EDIT - I should also mention that the parameter in question (#EventType) has no default value assigned.
How are you declaring your predicate for the variable? It should be be like:
where thing in (#Variable)
Where #Variable is a multi value parameter.
You could attempt to see if the values of the multi valued parameters are junked up somewhere as well by defining them. Generally the collection method of multi valued parameters can cause issues if there data types are different.
Also you may try to design your data set at runtime to build instead of being a static query. EG: Set up an expression for your dataset like:
="Select * from table where thing in (" & Parameters!Variable.Value & ")"
This would cause the parameter to build as part of a string and then evaluate at run time instead of from a traditional query.
Can't quite believe that this was the case, but the parameter which was passed to the SQL Server procedure was too small. It was defined as a VARCHAR(500) and needed to be bigger to deal with a large list of comma separated values. I changed it to VARCHAR(4000) and it's now functioning as expected.
Thanks to Djangojazz for pointing me to the direction of the parameter.
I am working on a SSRS report.
I have a parameter. the Value Field gives me IDs separated by delimiters, After user selection, I want the selected value field to be processed and put it in a variable then pass it to the main query to display the result. Please tell me how can I do that, do I need to use script, if yes, how can I? an early reply is appreciated. This is live production issue, so need to fix ASAP.
Thanks
Don't use a single value with IDs separated by delimiters. Instead, set your parameter to accept multiple values and amend your query accordingly.
I want to bring in all the values in a specific field to populate a parameter. I can do so, but I also want to add the word "..ALL" to the head of the list so the parameter essentially becomes optional.
When I choose a new data source, I don't seem to have the option of entering a SQL statement to pull the values, I can only choose a field to draw values from.
How do I do this?
You don't see the Add Command option right under the datasource name in the database expert? This let's you enter the sql so you can union the hardcoded 'ALL' option.
Or, you could always use a view or stored procedure.