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...
ردحذف.. thanx
please send me the .xpo file for this.. karthikeya.dax@gmail.com
ردحذفthanks.
Hello.. I need the .xpo for the above. Kindly send it to babu.dax2012@gmail.com...
ردحذف.. thanx
beautifully explained vishal, keep going........
ردحذفThanks Hussaini :)
حذف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
حذفThanks
Neat explanation...
ردحذفsend me xpo mohanydder@gmail.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
super
ردحذفplease send me the xpo file to christalen4u@gmail.com
ردحذفnice...please send me xpo to amolpatil187@gmail.com
ردحذفvery nice please share me the XPO to adityaraja63@gmail.com
ردحذفIt's very helpful.please send me the xpo file to kmayazahmed@gmail.com
ردحذفsuperb .... ple send XPO file to kothamasu.pavan91@gmail.com
ردحذفpls send me XOP file pramod6960@gmail.com
ردحذفHi Vishal,,
ردحذفIts 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
ردحذفvery good explanation... you cleared my doubts regarding surrogate key , replacement Key, forignkey relation, alternate key in single post..
ردحذفThanks.
Very good explanation with proper example. Thank you
ردحذفThanks sreekanth! :)
حذفThank you so much. Really it was very helpful.
ردحذفHi,
ردحذفIt is really helpful... You explained in a very detailed way.. Thanks a lot...
Very good explanation with proper example. Thank you
ردحذفThank you! keep reading :)
حذفits very easy for understanding .. very good explanation sir .. thank you
ردحذفsir can you give detail information about ssrs report classes .. how we can fill data in tmp table . please reply
ردحذفbharathkarunaece@gmail.com
ردحذفInformative blog.
ردحذفMS Dynamics AX Online Training
Thanks for sharing!!
ردحذفoversættelsestjeneste
Very good explanation with proper example. Thank you motorcycle key chain
ردحذف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
ردحذف