View source | Discuss this page | Page history | Printable version   

How to use property fields

Contents

Introduction

In MP13 the new concept: property field, was introduced. A property field allows you show derived information in a grid/form. A property field is very similar to a normal field in a tab. The only difference is that instead of the column, a property (path) is defined.

Property fields make it possible to:

Example Module

This howto is supported by an example module which shows example of the code shown and discussed in this howto.

The code of the example module can be downloaded from this mercurial repository: https://code.openbravo.com/erp/mods/org.openbravo.client.application.examples/

The example module is available through the Central Repository (See 'Client Application Examples'), for more information see the Examples Client Application project page.

Bulbgraph.png   The example module also contains implementations of other howtos.

Defining property fields

Property fields are defined in the same way as a normal field in an Openbravo tab. The only difference is that instead of selecting a column a property is set.


Howto-property-fields-define-field.png


The property can consist of multiple steps separated by a dot, the system will help you to set the correct property value. If you make a typo then the system will report an error.

Property fields are not editable in the user interface, they are however automatically updated when inserting or updating a record in the system.

Bulbgraph.png   Property fields are meant to show derived information. They should not be used to show the contents of a column stored in the table associated with the tab where the property field is being defined.

Using in validation rules

Property fields can be used (from PR15Q2) in Validations. In this case the validation code referencing the property field should look like @_propertyField_fieldName_columnname@ where fieldname is the name of the field property (lower case and removing blank spaces) and columnname is the name of the referenced column.

As field properties are only computed when the record is saved, but they are not reevaluated on field changes, only in case they refer a path coming from the record header should be used in validations. Example in Order Line you could use any property field taking the data from its order header.

Using in display logic

You can set a display logic that references a property field. The way of setting the display logic which references a property field is the following one: "@inp_propertyField_NameOfThePropertyField_ColumnName@". For example:

Use case: show related information

The first usage of a property field is to show related information in the user interface. The example in the previous section showed how to define a new business partner category field in the sales invoice header window/tab. This is visualized as follows in the user interface:


Howto-property-fields-show-field.png


And you can sort and filter on the related/derived field:


Howto-property-fields-show-field-sort.png


And also display it in the form:


Howto-property-fields-show-field-form.png


Note that direct linking also works for derived fields, so in this example you can 'jump' directly to the business partner category window for the business partner category.

Use case: show child table in top of the window

A great usage of the property field concept is to show child records (for example: sales invoice lines) in the root of a window. This then makes it possible to filter and sort the child records accross multiple parents (for example: sales invoice headers).

The screenshot below shows an example of a sales invoice line window which shows all sales invoice lines accross multiple sales invoice headers. It makes it really easy to filter and sort accross all sales invoice lines in the system.


Howto-property-fields-sales-invoice-line.png


Some things to note when creating these type of windows:


Howto-property-fields-sales-invoice-line-extra-field.png

Retrieved from "http://wiki.openbravo.com/wiki/How_to_use_property_fields"

This page has been accessed 15,458 times. This page was last modified on 22 June 2015, at 11:40. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.