Selector Example
Contents |
Introduction
The Business Partner selector is one of the most used selectors in the application. It allows the user pick a Customer, Vendor, etc in the the application. It composed by a drop-down list (picklist) where you can type to search, and a popup grid when you click the magnifier icon.
Objective
The main objective is to explain all the configuration settings made in the Business Partner selector. The current version of the selector is implemented as SmartClient FormItem and is using a Custom Query selector definition.
Application Dictionary definition
Reference
- Module: Core 3.0.x
- Name: Business Partner
- Parent Reference: Search
- In the Application Dictionary you'll find Base Reference and non Base Reference. A Base Reference defines a common behavior among all references extending from it. You could think of it as Class and Subclass analogy in Java. The Business Partner selector is not a Base Reference therefore you need to define the Parent Reference (Search) from which is extending behavior.
User Interface Definition
- Implementation class name: org.openbravo.userinterface.selector.reference.FKSelectorUIDefinition
- A non Base Reference can override the definition of its parent reference. In this case is overriding the Search Reference's User Interface implementation class. This class is in charge of provide field properties when generating code a window that contains a Business Partner selector. You can check the Java implementation checking the source code: FKSelectorUIDefinition.java
Defined Selector
- Module: Core 3.0.x
- Name: Business Partner with contact and location
- Template: Selector Template
- Custom Query: true
- When Custom Query is checked, the HQL field is displayed.
- Table: C_BPartner
- A column using this reference is a foreign key to the C_BPartner table.
- Entity alias: bp
- The alias used for the main entity used in the HQL query. Check the HQL and you'll see that BusinessPartner has an alias bp (FROM BusinessPartner bp ...)
- HQL:
SELECT distinct bp.name as name,bp.id as bpid, bp.searchKey as value, bp.creditLimit - bp.creditUsed as creditAvailable, bp.creditUsed as creditUsed, COALESCE(contact.name, usercontact.name) as contactname, COALESCE(contact.id, usercontact.id) as contactid, bploc.name as locationname, bploc.id as locationid, bp.customer as customer, bp.vendor as vendor, bp.lifetimeRevenueToDate as income FROM BusinessPartner bp left join bp.businessPartnerLocationList bploc left join bploc.locationAddress loc left join bploc.aDUserList contact left join loc.region region left join bp.aDUserList usercontact with usercontact.partnerAddress.id is null where @additional_filters@ and bp.summaryLevel = false
The Business Partner selector also shows the contacts and locations. The hql is joining with the associated entities. Notice in the where clause you have a constant @additional_filters@.
The @additional_filters@ appends automatically the implicit filter by Client and accessible Organizations. Notice that the client and organization filter is applied to the base table in the hql query. For eg., in the above query, the filters will be applied on the BusinessPartner bp table. Also, when filtering by an specific field in the popup grid, the Left Where Clause is appended in this location. See Defined Selector Field
- Display Field: Name
- Name of the field to be displayed in the field
- Suggestion Text Match Style: Starts with
- The text matching style with searching using the suggestion box
- Popup Text Match Style: Starts with
- The text matching style with filtering using the columns in the selector grid
Defined Selector Field
- Module: Core 3.0.x
- Name: Contact
- Name of the field
- Display Column Alias: contactname
- The alias matching the property alias in the HQL
- Reference: String
- Type of data: String, Number, Date, etc
- Show in Picklist: true
- If the field is displayed in the drop-down list
- Central Maintenance: true
- If the field is centrally maintained. See Element_and_Synchronize_Terminology
- Show in grid: true
- If the field is displayed in the popup grid
- Sorting of columns in grid: 6
- The position of this field in the grid
- Filterable: true
- If the field is can be used to filter data in the popup grid
- Sortable: true
- If the field can be used to sort data in the popup grid
- Clause Left Part:
COALESCE(contact.name, usercontact.name)
This part is the left side of the expression when filtering using this field. This expression is transformed in COALESCE(contact.name, usercontact.name) like 'value' where value is the text entered by the user in the popup grid. The like operator is based on the text matching style.