Compiere is designed to allow for easy customization and extension. Often these changes will include adding new field to existing tables.
You can allow users total freedom in the data entry process (text field), provide them with a list that users can modify (table) or control the list (reference). Which is the best option will depend upon how the field is used.
For example, you may want to add a field that displays the type of Business Partner in the Business Partner window. Adding the field BPartnerType to the Business Partner window is a simple task that has been described in earlier blog entries. What we will discuss here is the different options for how the field is populated.
The simplest method is simply to define the field as a text field and the user simply enters data in it, like Wholesale, Government, Retail etc. This approach is fine if the data is simply for display purposes only and you do not want to perform any reporting or analysis using that field. If you allow free text entry one person may enter WHOLESALE and another Wholesale while a third may use Wsale. This would make any type of reporting or anaylsis difficult.
A better option would be to have the users select from a list of values. This ensures uniform data and easier reporting and analysis. There are two ways to have the list populated, using a Table Lookup or a Reference List. As expected, there are different scenerios which make one a better option that the other.
Table Lookup
Using a table lookup is the best approach if the users control the data. After signing in as System Administrator:
- Define a new Table in window "Table and Column" that will store the appropriate vales for the Business Partner Type.
- Create a Window based on this table (in window "Window, Tab and Field").
- Add the Business Partner Type field in the Business Partner table and set the Reference to Table, TableDir or Search (depending upon the number of values you expect).
- Set Security for Users who would be repsonsible for adding the appropriate selections (Retail, Wholesale, Government) to allow access to the new Business Partner Type window to ensure good data. (if your roles are not defined as Manual just run Role Access Update)
This is a good approach if the users will provide appropriate values and if values are added on a regular basis. You can see an example of this type of implementation in the Business Partner window in the Business Partner Size field.
Reference List
Another option is to provide the user with a predefined list of values, users do not need to update. This uses Reference Lists:
- Define a window "Reference" create a new entry with the type of List.
- Add the appropriate values the List tab.
- Add the Business Partner Type field in the Business Partner table, set the Reference to List and in the Reference Key select the Reference List defined in step 1.
The users have no access to the definition of the list of values, they simply select from the list in the Business Partner window. This is a good approach if you want to tightly control the list of values that are displayed. This is also the recommended approach if there are any processes that will use the value in this field. In that case, code is looking for a specific value and if one were added without the appropriate code, the system will not behave as the user expects.
For example, look at the Delivery Rule on a Sales Order. The user has a list of values they can select from, but they cannot add any new ones to the list. If a new value was added by the System Administrator and no java code was added to the generate shipments process for this new value, a shipment would never be generated for this order.
So the choice is yours. Which is the best option will depend upon how the field is used.