Table Inheritance In Microsoft Dynamics Ax 2012

Table Inheritance :

  • A table can extend from or derive from another table. Each table has the SupportInheritance property and the Extends property, which together control table inheritance.
  • The default for each new table is to implicitly extend from the Common table. The extension from the Common table cannot be set or seen in the Extends property. A variable that is declared of a specific table also implicitly inherits methods from the xRecord class.
  • In the terminology for table inheritance, we say that the derived table extends its base table. But we never use the terms parent or child to explain tables in an inheritance relationship. The terms parent and child can be used to describe foreign key relationships between tables.
  • In Microsoft Dynamics AX, a table can inherit from another table. The AOT node for each table has the Extends property which you can use to derive your table from a table that you specify. 

Table inheritance is mainly controlled by the following properties:

  1. SupportInheritance – specifies if a table is a part of a hierarchy.
  2. InstanceRelationType – specifies the field that is used as a type discriminator. TableIds of concrete types are used as values of the InstanceRelationType field.
  3. Abstact – specifies if a table is abstract. Tables without derived tables cannot be abstract.
  4. Extends – specifies table’s parent.


Small Simple Example to understand Table Inheritance more easily

Step-1 Create a table called BaseTable
Step-2 Set table property supportInheritance to Yes
Step-3 Create a field name called InstanceRelationType extends RelationType
Step-4 Set table property InstanceRelationType to InstanceRelationType

Step-5 Create two field called Id and Name as shown below screen



Step-6 Create another table called ChildTable
Step-7 Set table property supportInheritance to Yes
Step-8 Set table property Extends to BaseTable



Step-9 Lets write a job to access the base table fields.
(Simple job to demonstrate how to insert data into the child table without creating the fields,properties in the child table)

static void dataInsert_BaseTable(Args _args)
{
              ChildTable     childTable ;

              childTable .Id = '1000';
              childTable .Name = 'Test';
              childTable .insert();
}



Note: When you upgrade from Microsoft Dynamics AX 2009 to Microsoft Dynamics AX 2012, some tables are converted to use table inheritance. If you have customized those tables in Microsoft Dynamics AX 2009, the upgrade system is not able to upgrade those tables.

That's it we are done with basics of table inheritance. 
Proud To Be a DAX Developer :-) 

2 comments: