Query script not run in suggest box - suggestbox

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

Related

Loop through database ANYLOGIC

In my model I want to loop through the database which contains multiple columns (see example) by an event. The idea behind it is that I want to create dynamic events based on the rows in the database.
But I've no clue how to iterate through a database in anylogic and also was not able to find an example of a loop with a database.
The dummycode of my problem would look something like this:
For order in orderdatabase:
Create order based on (order.name, order.quantity, order.arrivaltime, order.deliverylocation)
Where order in the loop is every row of the database, and the value on which the creation is based based on the different column values of that specific row.
Can somebody give me a simple example of how to create such a loop for this specific problem.
Thanks in advance.
Use the database query wizard:
put your cursor into a code field
this will allow you to open the database wizard
select what you need (in your case, you want the "iterate over returned rows and do something" option
Click ok
adjust the dummy code to make it do what you want
For details and examples, check the example models and the AnyLogic help, explaining all options in detail.

How to relate a column to the row rather than the other way in anylogic

I have created a database in anylogic. Previously, I have related the information in the row to the columnn, i.e. there is a component in the row, and its properties are in the columns, and have put this in a function. Now I want to make the component the column and the properties, but don't know how to make it all relate. Below is the code I've written for the former:
site = selectFrom(parameters) .where(parameters.box_number.eq(boxNumber)) .where(parameters.site.eq(site)) .firstResult(parameters.site);
So box_number is the component and site is one of the properties. With this method, site is a column, but I want it to be a row.
You should use the SELECT WHERE SQL syntax, see https://help.anylogic.com/index.jsp?topic=%2Fcom.anylogic.help%2Fhtml%2Fconnectivity%2Fquerying.html&resultof=%22%73%65%6c%65%63%74%22%20%22%77%68%65%72%65%22%20
You can filter and load data in any format. Also, best use the database query wizard to help:

Jasperreport parameter selection from SQL query

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.

JasperServer: using user locale in query for input control

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.

Adding "..ALL" to a dynamic parameter

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.