Overview
This is a field which can be used for a single choice, or multiple to make one or more choices from a list. The 'value' property determines what selected option value will be populated in the field when the program gets the screen input. When the program outputs to the screen, it attempts to match what is in the 'value' field property should match to an option in of the select box; if it does not, the select box . If no match is present the first options is selectedwill show as empty. Note: for the 'value' to match one of the options of the select box, the formatting of the 'value' and option must also be the same. The list of choices can be loaded in a variety of ways, please see below for more detail.
Validation (Rich UI Only)
Please visit the Validation and Error Messages page.
Field Binding Dialog (Rich UI Only)
Please visit the Field Binding page.
Select Box Properties
select box height - This property is used to convert the select box to a List Box and displays the choices in a selectable list instead of the dropdown box.
multiple - This specifies that multiple values can be selected from the select box. The default value of the property is 'false'. If set to 'true' the select box will convert to a List Box.
Choices / Choice Values Properties
These properties can be used to set the list of options in the select box:
...
- Comma separated list - A simple list of values separated by just a comma (i.e. Option 1, Option 2, Option 3, etc...).
- JSON array format - Using JSON array format, meaning the choices/values are enclosed in a bracket with quotations and then comma separated (i.e. ["ElementOne", "ElementTwo", "ElementThree"] ) within the choices and choice values fields also allows you to populate the auto-complete.
Database-Driven Selection
This section allows choices/choice values to be retrieved from a database file.
Choices database file - Enter the database file to use to populate populate your options/values. When setting your database file it's not required to qualify with library name, although you can. if the library is omitted, the application job's library list will be used.
...
Choice selection criteria - This acts as a WHERE clause in an SQL statement to filter your criteria. SQL parameter markers are always specified by a question mark (?). The property "choices parameter value" can be used to provide the value for this parameter marker.
This will produce an SQL statement like this:
Code Block |
---|
SELECT DISTINCT CNAME, CATID FROM CATEGP WHERE CNAME = ?
|
Choice parameter value - This is where the choice selection criteria value for '?' is set. This value may also be bound to a field (Rich UI only).
By completing the choice parameter value we can see our statement should return only the items named "Soaps". You can have multiple "parameter value" properties, however this does require multiple choices selection criteria. These can be added by right-clicking the choices parameter value property name and selecting "Add Another Choices Parameter Value":
For Rich Display Files the choices parameter values would usually be bound to a field allowing dynamic SQL selection.
To find more information on the choice selection criteria and choices parameter properties, view the Parameter Markers section here.
Blank Option
The blank option property allows you to provide a option containing blank text before any other choices from the database file are displayed.
...
Both 'blank option' and 'blank option label' properties can only be used with a Database-Driven selection. These properties may also be assigned to a bound field. (Rich UI only).
Order By
Optional expression that allows you to specify which fields determine the order of the items in the list. This is equivalent to the ORDER BY clause used in SQL statements. The default behavior of this property is to show the items in ascending order. You can add DESC to this property to sort in descending order. For example:
This will sort by product id (PRID) in descending order.
Max Choices
The max choices property allows you to set the number of choices you will see from your database-driven selection. There is no limit to the number of choices you can show, however if there is no limit set the default is 10.
Dynamic Auto-Complete
Choices URL
The choices URL property allows you to use an external program to return your choice options and values by passing them using JSON formatting. A PHP script would be one example of a custom program PHP scripts or Universal Display Files are examples of custom programs used to pass the values to your application. When using the choices URL property, all database-driven auto-complete properties are ignored.
...
These are values returned from an auto-complete select box in a successful response from the external program:
Code Block | ||||
---|---|---|---|---|
| ||||
{ "success":true, "response":[ {"text":"Dishes and Cups", "value":"18"}, {"text":"Soaps", "value":"14"} ] } |
Code Block | ||||
---|---|---|---|---|
| ||||
{
"success":true,
"response":[
new Option("Dishes and Cups","18"),
new Option("Soaps","14")
]
}
|
...
This example is JSON information returned when the script encounters an error with an database driven auto-complete.
Code Block |
---|
{ "success":false, "errorId":"-204", "errorText":"CATEG in *LIBL type *FILE not found.", "errorText2":"SQLPrepare()" } |
If you are unable to get any information to display on your choice URL script you can use the showErrors() API to try and debug the reason the results are unable to display.
showErrors() API Documentation
Example of the showErrors() API displaying JSON error response example:
PHP Script Example: