Entity_common.4gl
For schemas, form entities, report entities, and Web Service entities in a BAM diagram, a .4gl file is created to contain the model.
This file uses the filename of the entity with the _common suffix and the .4gl extension. For example, a form named OrderForm.4fdm generates a file called OrderForm_common.4gl.
Do not write to this common file (entity_common.4gl) as your changes will not persist. The file is regenerated with each build.
The entity_common.4gl defines the constants, types, and variables specific to the event code module. In entity.4gl, you can access this model using auto completion.
the m_filter record
If you have a filter defined for the relation between two forms, the receiving form includes a record variable named m_filter, defined in entity_common.4gl. This variable will contain the values passed from the sending form to the receiving form in the fields defined by the filter.
Why is this important? While the filter can be used to limit what is initially displayed, the user may add a new record or query for a record that is not constrained by the filter. You may need to add custom code to ensure that any new or modified rows continue to meet the filter of the criteria, as stored in the m_filter variable.
For example, consider the relation between two forms, from an employee.4fdm form to the
bonus.4fdm form. There is a filter on the relation, where employee.emp_num
is the
Source Field and bonus.emp_num
is the Destination Field. The bonus_common.4gl file
defines the m_filter record with the fields bonus_emp_num
,
bonus_create_date
, and bonus_amt
; however, the only value contained in the record is
the value of emp_num
that was set when moving from one form to the next.
When adding your own custom code, you can use this variable to set a field equal to the value sent across. For
example, In the bonus.4fdm file, in the Record tab, you create On Default
Values custom code. In the bonus.4gl file, in the dataEvent_record_OnDefaultValues
function, you type the following:
LET currentRow.bonus_emp_num = m_filter.
bonus_emp_num
, resulting
in:LET currentRow.bonus_emp_num = m_filter.bonus_emp_num