There is a new pattern for adding fields to standard tables that has been used from AX 2012 R2, wherein fields are actually added to an extension table. This would be joined to the primary table in a 1:1 join. This seems like a silver bullet—we can add fields to a standard table without modifying it!
There are two main limitations with this, from the footprint perspective.
delete
action (or add an event handler to the delete
method) must be placed on the parent table, otherwise, we will have orphaned records if the parent is deleted.Of course, we still have to modify the forms to show the fields. However, this is the same for both the methods. Therefore, to add a single field to a standard table involves more work, but with advantages, for example, all of the table and field event handling for the new fields are completely separate from the standard table.
There is a performance benefit on updates when only the standard or extension table needs to be updated, although this is mitigated by having to first seek the parent table to get the extension table record. It also avoids potential buffer size issues when adding a large number of fields, such as note fields.
There is nothing new here that we haven't done before, so we will just list the steps required. We will take an example of CustTable
; the steps involved in implementing this pattern are as follows:
ConCustTableExt
and add a primary key relation to CustTable
, which will create a field named CustTable
on our new table.CustTable
; name it ConCustTableExtHandler
.deleteEventHandler
that will locate and delete the extension record.delete
method.CustTable
and set the JoinSource property to CustTable
.CustTable
, and add the following code after the call to super()
:if (!ConCustTableExt.RecId) { ConCustTableExt.CustTable = custTable.RecId; ConCustTableExt.write(); }
You can then proceed to add fields as required to the form. In terms of deployment, you will have to handle the situation where there are customers without the extension table. This can be done by adding code to the form or writing a data initialization routine.
3.145.125.51