But there are certain table keys which are difficult to understand just
by the definition, something like “Replacement key”. So let me then showcase
the practical scenario like how you can use it and the benefit of having that
property in your table.
What is replacement key??
A replacement key is an alternate key that the system can display on
forms instead of a meaningless numeric primary key value. Each table can have a
maximum of one replacement key.
The replacement key is chosen by setting theReplacementKeyproperty on the table. The drop-down list offers every alternate key as
an available value.
The drop-down list contains every index that
has its AlternateKey property set to Yes.
You might change the default blank value to
an index whose field values within each record provide a name or other moniker
that is meaningful to people. If a ReplacementKey is chosen, its
fields can appear on forms to helpfully identify each record.
The ReplacementKey should be a set
of fields that represent the natural key.
Now let’s look at it in AX 2012, how we can create this key and how
does it look.
Firstly am going to create a simple table called “EmployeeTable” which
contains 3 fields emplId, Name and DOB (dateofbirth).
And now going to create index on this table where “AllowDuplicate”
property should be set as ‘NO’ and alternate key property as ‘YES’ .As shown
below:
Once the creation of index is done then we can easily assign the
replacement key to this table as shown here in the below image.
Now creating another table called “EmployeeTransactions” which contains
2 fields TotalAmountCharged and TotalHourWorked.
In order to give relation with EmployeeTable, creating foreign key
relations and as soon as we do that automatically new field (EmployeeTable) got
added in our “EmployeeTransactions” table. As shown in below image:
Now, I can say that relation exist between the two tables and relation
is RecId field of employeetable to that of newly created employeeTable field (Int64
– datatype).
NOTE:
You can also achieve this relations using EDT.
Now let’s create some line in to these tables and check how and what it
stores in to employeetable field in ‘employeetransaction’ table.
As we have seen from backend, table stores the INT64 field i.e., recId
of related ‘employeetble’ record.
Since form is the artifact which is user oriented (Client interface). Now
let’s create a form and check how it appears there. So am just creating a
simple form which consist of these two table as datasource and using the
joinsource property to join them. Form structure looks something like this:
So basically, header and line part in form represents “employeetable”&”
employeetransaction”. Here in header part details can be filled up & emplid
can be easily accessed and if you look at the line level there is a field
called reference which I dragged from transaction datasource > emloyeetable
field. For reference, just look at the form image above.
Now here comes the magic J as
soon as you create & save the record in header then line level reference
gets filled up with related emplid field. But if you look at the backend in
tables it would be stored as recid.
So I can say that Alternate key allows the system to display significant
value on forms instead of a meaningless numeric primary key value. Each table
can have a maximum of one replacement key.
Thus with this we are done with the Replacement key
functionality in AX 2012 R2. Please input your email-id, if you are looking for
XPO of it.
Hi Vishal, it really helped me a lot to understand the replacement key concept. Request you to please send me the xpo on my email id: nagesh_singh1978@hotmail.com
Hi Vishal, It's very helpful. when i made the relation of employee table with the employeetransactions using the foreign key>'single field alternate key based' the dropdown value in the employeetable field of the employeetransactions shows the alternate key field values directly instead of the int64 values. Please comment
This is a great article thanks for this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post. mobile locksmith bakersfield
Hello.. I need the .xpo for the above. Kindly send it to vivek1989maheshwari@gmail.com...
ReplyDelete.. thanx
please send me the .xpo file for this.. karthikeya.dax@gmail.com
ReplyDeletethanks.
Hello.. I need the .xpo for the above. Kindly send it to babu.dax2012@gmail.com...
ReplyDelete.. thanx
beautifully explained vishal, keep going........
ReplyDeleteThanks Hussaini :)
DeleteHi Vishal, it really helped me a lot to understand the replacement key concept. Request you to please send me the xpo on my email id: nagesh_singh1978@hotmail.com
DeleteThanks
Neat explanation...
ReplyDeletesend me xpo mohanydder@gmail.com
ReplyDeleteHi Vishal,
ReplyDeleteIt's very helpful. when i made the relation of employee table with the employeetransactions using the foreign key>'single field alternate key based' the dropdown value in the employeetable field of the employeetransactions shows the alternate key field values directly instead of the int64 values. Please comment
super
ReplyDeleteplease send me the xpo file to christalen4u@gmail.com
ReplyDeletenice...please send me xpo to amolpatil187@gmail.com
ReplyDeletevery nice please share me the XPO to adityaraja63@gmail.com
ReplyDeleteIt's very helpful.please send me the xpo file to kmayazahmed@gmail.com
ReplyDeletesuperb .... ple send XPO file to kothamasu.pavan91@gmail.com
ReplyDeletepls send me XOP file pramod6960@gmail.com
ReplyDeleteHi Vishal,,
ReplyDeleteIts very good explanation.. My point on replacement key is cleared now..
Thank yoou.
i want all the relations and execution steps ,why we use them
ReplyDeletevery good explanation... you cleared my doubts regarding surrogate key , replacement Key, forignkey relation, alternate key in single post..
ReplyDeleteThanks.
Very good explanation with proper example. Thank you
ReplyDeleteThanks sreekanth! :)
DeleteThank you so much. Really it was very helpful.
ReplyDeleteHi,
ReplyDeleteIt is really helpful... You explained in a very detailed way.. Thanks a lot...
Very good explanation with proper example. Thank you
ReplyDeleteThank you! keep reading :)
Deleteits very easy for understanding .. very good explanation sir .. thank you
ReplyDeletesir can you give detail information about ssrs report classes .. how we can fill data in tmp table . please reply
ReplyDeletebharathkarunaece@gmail.com
ReplyDeleteInformative blog.
ReplyDeleteMS Dynamics AX Online Training
Thanks for sharing!!
ReplyDeleteoversættelsestjeneste
Very good explanation with proper example. Thank you motorcycle key chain
ReplyDeleteThis is a great article thanks for this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post. mobile locksmith bakersfield
ReplyDelete