To implement the table extension framework in Dynamics AX 2012 R3, following are the steps:
Assume that you have table SalesLine and you want to make extension table ISPLSalesLineExtension.
At SalesLineExtension table, add new relation named SalesLine, table SalesLine.
Add a new field ForeignKey -> PrimaryKey based at newly created ISPLSalesLineExtension table. Reference field to the primary table will be added automatically.
Note: if the parent table’s primary key is not RecId-based, but the table has CreateRecIdIndex property set to Yes, then the relation on step #1 should be created based on “Single field AlternateKey based”; otherwise the new field will potentially have wrong type, and it will not be possible to use it in the SysExtensionSerializerExtensionMap map.
Add parent table (SalesLine – If it is standard table it might already be exist) to SysExtensionSerializerMap and child table (ISPLSalesLineExtension) to SysExtensionSerializerExtensionMap
This field is available in standard table (Check if already exists)
Check if code already exists if it is a standard table.
public void insert()
{
super();
this.SysExtensionSerializerMap::postInsert();
}
public void update()
{
super();
this.SysExtensionSerializerMap::postUpdate();
}
public void write()
{
super();
ISPLSalesLineExtension.SysExtensionSerializerExtensionMap::insertAfterBaseTable(SalesLine);
}
Write Method of child table triggers first and as a result child record will not be saved as it’s insert and update methods does not allow it without correct foreign key.
Feel free to contact us in case of any query.