How to hide record type selection dialog from inherited table form in Dynamics AX
Views (1585)
Hi,
In this post i will discuss a very critical scenario to which all of us may deal with, when ever we are working with Table Inheritance feature of Dynamics AX.
Suppose we are creating a form, so whenever a Base table(TabPet) that has derived tables(TabPetDog & TabPetBird) is added on a form as a datasource, all its children(Derived tables) are added under the Derived Datasources node. Fields from the Primary & Derived Data Sources can be bound to form controls in order to show records from different table types.The structure of the tables & from is shown below.
Now when the user attempts to create a new record in the form by clicking the new button, the Microsoft Dynamics AX 2012 client framework dynamically creates a type picker dialog and populates the list that prompts the user to select the type of the record to be created, as shown in Figure below.The list includes all the concrete table types that derive from the table serving as the data source for the form.
Often, you do not want the system default type picker dialog to be displayed when creating new records because of certain constraints imposed by the application requirements. If this is the case and you want to create record directly by bypassing the type picker dialog, here is an easy method/technique that will do all for you that is it will bypass or hide the type picker dialog and automatically create the desired record type.
Simply Override the CreateRecord method of the form and in that, invoke the FormDatasource.CreateTypes method to create a new record of the specified concrete type as shown below.
public void createRecord(str _formDataSourceName, boolean _append = false)
{
Map typesToCreate = new Map(Types::String, Types::String);
// To create record in Parent table (TabPet)
typesToCreate.insert(_formDataSourceName,tableId2name(tableNum(TabPet)));
// To create record in Derived table (TabPetDog)
typesToCreate.insert(_formDataSourceName,tableId2name(tableNum(TabPetDog)));
// To create record in Derived table (TabPetBird)
typesToCreate.insert(_formDataSourceName,tableId2name(tableNum(TabPetBird)));
TabPet_ds.createTypes(typesToCreate);
// super(_formDataSourceName, _append);
}
Note: In the above code use any appropriate typesToCreate.insert() according to your requirement of creating record types.Here i have shown how different record types (Primary or Derive) can be created by passing appropriate Datasources as parameters.
That's it we are done.
Happy Coding :)
In this post i will discuss a very critical scenario to which all of us may deal with, when ever we are working with Table Inheritance feature of Dynamics AX.
Suppose we are creating a form, so whenever a Base table(TabPet) that has derived tables(TabPetDog & TabPetBird) is added on a form as a datasource, all its children(Derived tables) are added under the Derived Datasources node. Fields from the Primary & Derived Data Sources can be bound to form controls in order to show records from different table types.The structure of the tables & from is shown below.
Often, you do not want the system default type picker dialog to be displayed when creating new records because of certain constraints imposed by the application requirements. If this is the case and you want to create record directly by bypassing the type picker dialog, here is an easy method/technique that will do all for you that is it will bypass or hide the type picker dialog and automatically create the desired record type.
Simply Override the CreateRecord method of the form and in that, invoke the FormDatasource.CreateTypes method to create a new record of the specified concrete type as shown below.
public void createRecord(str _formDataSourceName, boolean _append = false)
{
Map typesToCreate = new Map(Types::String, Types::String);
// To create record in Parent table (TabPet)
typesToCreate.insert(_formDataSourceName,tableId2name(tableNum(TabPet)));
// To create record in Derived table (TabPetDog)
typesToCreate.insert(_formDataSourceName,tableId2name(tableNum(TabPetDog)));
// To create record in Derived table (TabPetBird)
typesToCreate.insert(_formDataSourceName,tableId2name(tableNum(TabPetBird)));
TabPet_ds.createTypes(typesToCreate);
// super(_formDataSourceName, _append);
}
Note: In the above code use any appropriate typesToCreate.insert() according to your requirement of creating record types.Here i have shown how different record types (Primary or Derive) can be created by passing appropriate Datasources as parameters.
That's it we are done.
Happy Coding :)
This was originally posted here.

Like
Report
*This post is locked for comments