Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / DynamicsAXWorld / Table Inheritance in Ax 2012

Table Inheritance in Ax 2012

In Microsoft Dynamics AX 2012, tables can inherit, or extend, from the tables that are situated above them in a hierarchy.
A base table contains fields that are common to all tables that derive from it

– The table properties “Extends”, “SupportInheritance” are used in the table inheritance hierarchy
– Table inheritance hierarchy can only be defined on a normal table type but not on tempdb, InMemory
– A type discriminator field must be defined on any table inheritance hierarchy created in the AOT.
the field must be defined as an int64 type on the root table, with the name of the field set to InstanceRelationType.
Furthermore, the developer must select this field as the value for the InstanceRelationType table property on the root table.
– In all the tables of inheritance hierarchy, the SupportInheritance property is set to Yes.Extends is set to the required tables

Do not create any fields in the table before completing the table hierarchy

Note: Field names must be unique across the entire table inheritance hierarchy.
This requirement ensures that the field name uniquely identifies the field across the hierarchy
when appearing in system APIs that reference table fields.
Developers will also notice that field IDs are unique across the entire table inheritance hierarchy

– If you are displaying the instance type of the record on a form, and a report is needed then a enumerationt ype can be defined on the  base table with the values as the types of tables in the hierarchy

Override the insert table method on the base table and write the code as follows
For eg: Partytype enum on party table

DictEnum enumType = new DictEnum(enumnum(partytype));
int enumValue;
if (this.DisplayRelationType != partytype::Unknown)
{
return;
}
enumValue = enumType..symbol2Value(this.getInstanceRelationType());
if (enumValue == 255) // symbol2Value returns 255 if cannot convert
{
throw error(strfmt(‘No %1 enum element found for EnumValue %2’,
enumstr(partytype),
this.getInstanceRelationType()));
}
else
{
this.DisplayRelationType = enumValue;
}
super();

– Developers can now use a new developer tool, the Type hierarchy browser to visualize the table inheritance hierarchy in a more intuitive way. 

Developers can access the tool by right clicking the AOT Tables node,
and then clicking Add Ins > Type hierarchy browser

 

 

Comments

*This post is locked for comments