I want to explain how to use replacement key functionality on AX 2012.
D365FO has the same ability too.
Replacement key helps you to link your parent child tables through the parent table RecId value but on the user interface it will display the string data that makes more sense to the user.
With this ability you don't have to struggle with preparing unique string field to link parent and child table which we all know it could be a nightmare.
Let's start with how can we activate replacement key functionality on AX 2012
First create the parent table
Table name is ParentTable and it has two fields Id and Name. Id field is the unique field.
After creating the index change the Allow Duplicates property to No and change the Alternate Key to yes.
On table properties you should be able to find your index name under ReplacementKey. There can be only one replacement key per table.
Parent table is ready now create the Child table with one field ChildName
When you create a relation on child table with the parent table and select PrimaryKey based option system will create the relation field on child automatically and link to this relation.
Save your table and create a new form to test. Form has ChildTable as datasource and two fields child name and parentTable fields. If you noticed the parentTable field type is referenceGroup that means it will store the data as RefRecId but will display the id of the parent to the user instead.
Adding some test data to parent table and opening the child details form
Lookup has the records to choose but are we need the names too to know which id belongs to which name.
Solution is simple just add the details fields to the AutoLookup field group on the ParentTable.
We have names now to choose the correct parent now.
After user saves the records system fill the reference field.
Hope this helps you to link tables, see you next time!
Alper.
Comments
Post a Comment